Set permissions for the updater binary after updating it.
This commit is contained in:
parent
595e4b697e
commit
c816a26647
@ -528,7 +528,12 @@ void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish
|
|||||||
|
|
||||||
QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" ");
|
QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" ");
|
||||||
|
|
||||||
QProcess::startDetached(updaterBinary, args);
|
QFile::setPermissions(updaterBinary, (QFileDevice::Permission) 0755);
|
||||||
|
if(!QProcess::startDetached(updaterBinary, args))
|
||||||
|
{
|
||||||
|
QLOG_ERROR() << "Failed to start the updater process!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we've started the updater, quit MultiMC.
|
// Now that we've started the updater, quit MultiMC.
|
||||||
MMC->quit();
|
MMC->quit();
|
||||||
|
@ -412,6 +412,7 @@ DownloadUpdateTask::processFileLists(NetJob *job,
|
|||||||
if (isUpdater)
|
if (isUpdater)
|
||||||
{
|
{
|
||||||
download->setProperty("finalPath", entry.path);
|
download->setProperty("finalPath", entry.path);
|
||||||
|
download->setProperty("finalPerms", entry.mode);
|
||||||
connect(download.get(), &MD5EtagDownload::succeeded, this, &DownloadUpdateTask::directDeployFile);
|
connect(download.get(), &MD5EtagDownload::succeeded, this, &DownloadUpdateTask::directDeployFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,11 +550,16 @@ void DownloadUpdateTask::directDeployFile(const int index)
|
|||||||
{
|
{
|
||||||
Md5EtagDownloadPtr download = std::dynamic_pointer_cast<MD5EtagDownload>(m_filesNetJob->operator[](index));
|
Md5EtagDownloadPtr download = std::dynamic_pointer_cast<MD5EtagDownload>(m_filesNetJob->operator[](index));
|
||||||
const QString finalPath = download->property("finalPath").toString();
|
const QString finalPath = download->property("finalPath").toString();
|
||||||
|
bool ok = true;
|
||||||
|
int finalMode = download->property("finalPerms").toInt(&ok);
|
||||||
|
if(!ok)
|
||||||
|
finalMode = 0755;
|
||||||
QLOG_INFO() << "Replacing" << finalPath << "with" << download->m_output_file.fileName();
|
QLOG_INFO() << "Replacing" << finalPath << "with" << download->m_output_file.fileName();
|
||||||
if (QFile::remove(finalPath))
|
if (QFile::remove(finalPath))
|
||||||
{
|
{
|
||||||
if (download->m_output_file.copy(finalPath))
|
if (download->m_output_file.copy(finalPath))
|
||||||
{
|
{
|
||||||
|
QFile::setPermissions(finalPath, (QFileDevice::Permission) finalMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user