Merge pull request #2906 from TheKodeToad/no-recursive-remove-on-update
Prevent directories from being removed on instance update
This commit is contained in:
commit
bd01c47dc9
@ -38,22 +38,29 @@ void InstanceCreationTask::executeTask()
|
|||||||
// files scheduled to, and we'd better not let the user abort in the middle of it, since it'd
|
// files scheduled to, and we'd better not let the user abort in the middle of it, since it'd
|
||||||
// put the instance in an invalid state.
|
// put the instance in an invalid state.
|
||||||
if (shouldOverride()) {
|
if (shouldOverride()) {
|
||||||
|
bool deleteFailed = false;
|
||||||
|
|
||||||
setAbortable(false);
|
setAbortable(false);
|
||||||
setStatus(tr("Removing old conflicting files..."));
|
setStatus(tr("Removing old conflicting files..."));
|
||||||
qDebug() << "Removing old files";
|
qDebug() << "Removing old files";
|
||||||
|
|
||||||
for (auto path : m_files_to_remove) {
|
for (const QString& path : m_files_to_remove) {
|
||||||
if (!QFile::exists(path))
|
if (!QFile::exists(path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
qDebug() << "Removing" << path;
|
qDebug() << "Removing" << path;
|
||||||
if (!FS::deletePath(path)) {
|
|
||||||
qCritical() << "Couldn't remove the old conflicting files.";
|
if (!QFile::remove(path)) {
|
||||||
emitFailed(tr("Failed to remove old conflicting files."));
|
qCritical() << "Could not remove" << path;
|
||||||
return;
|
deleteFailed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deleteFailed) {
|
||||||
|
emitFailed(tr("Failed to remove old conflicting files."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user