aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCreationTask.cpp
blob: a82bdfe8a797921ca982f6193354aa6a7eba188d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "InstanceCreationTask.h"

#include <QDebug>

InstanceCreationTask::InstanceCreationTask() = default;

void InstanceCreationTask::executeTask()
{
    setAbortStatus(true);

    if (updateInstance()) {
        emitSucceeded();
        return;
    }

    // When the user aborted in the update stage.
    if (m_abort) {
        emitAborted();
        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()) {
        emitSucceeded();
        return;
    }

    qWarning() << "Instance creation failed!";
    if (!m_error_message.isEmpty())
        qWarning() << "Reason: " << m_error_message;
    emitFailed(tr("Error while creating new instance."));
}