aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCreationTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/InstanceCreationTask.cpp')
-rw-r--r--launcher/InstanceCreationTask.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/launcher/InstanceCreationTask.cpp b/launcher/InstanceCreationTask.cpp
index a82bdfe8..1b1a8c15 100644
--- a/launcher/InstanceCreationTask.cpp
+++ b/launcher/InstanceCreationTask.cpp
@@ -1,6 +1,7 @@
#include "InstanceCreationTask.h"
#include <QDebug>
+#include <QFile>
InstanceCreationTask::InstanceCreationTask() = default;
@@ -19,19 +20,37 @@ void InstanceCreationTask::executeTask()
return;
}
- // If this is set, it means we're updating an instance. Since the previous step likely
- // removed some old files, we'd better not let the user abort the next task, since it'd
- // put the instance in an invalid state.
- // TODO: Figure out an unexpensive way of making such file removal a recoverable transaction.
- setAbortStatus(!shouldOverride());
+ if (!createInstance()) {
+ if (m_abort)
+ return;
- if (createInstance()) {
- emitSucceeded();
+ qWarning() << "Instance creation failed!";
+ if (!m_error_message.isEmpty())
+ qWarning() << "Reason: " << m_error_message;
+ emitFailed(tr("Error while creating new instance."));
return;
}
- qWarning() << "Instance creation failed!";
- if (!m_error_message.isEmpty())
- qWarning() << "Reason: " << m_error_message;
- emitFailed(tr("Error while creating new instance."));
+ // If this is set, it means we're updating an instance. So, we now need to remove the
+ // 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.
+ if (shouldOverride()) {
+ setAbortStatus(false);
+ setStatus(tr("Removing old conflicting files..."));
+ qDebug() << "Removing old files";
+
+ for (auto path : m_files_to_remove) {
+ if (!QFile::exists(path))
+ continue;
+ qDebug() << "Removing" << path;
+ if (!QFile::remove(path)) {
+ qCritical() << "Couldn't remove the old conflicting files.";
+ emitFailed(tr("Failed to remove old conflicting files."));
+ return;
+ }
+ }
+ }
+
+ emitSucceeded();
+ return;
}