2016-10-03 04:25:54 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BaseVersion.h"
|
2018-03-19 07:06:12 +05:30
|
|
|
#include "InstanceTask.h"
|
2016-10-03 04:25:54 +05:30
|
|
|
|
2022-07-08 05:01:24 +05:30
|
|
|
class InstanceCreationTask : public InstanceTask {
|
2018-07-15 18:21:05 +05:30
|
|
|
Q_OBJECT
|
2022-07-08 05:01:24 +05:30
|
|
|
public:
|
|
|
|
InstanceCreationTask();
|
|
|
|
virtual ~InstanceCreationTask() = default;
|
2016-10-03 04:25:54 +05:30
|
|
|
|
2022-07-08 05:01:24 +05:30
|
|
|
protected:
|
|
|
|
void executeTask() final override;
|
2016-10-03 04:25:54 +05:30
|
|
|
|
2022-07-08 05:01:24 +05:30
|
|
|
/**
|
|
|
|
* Tries to update an already existing instance.
|
|
|
|
*
|
|
|
|
* This can be implemented by subclasses to provide a way of updating an already existing
|
|
|
|
* instance, according to that implementation's concept of 'identity' (i.e. instances that
|
|
|
|
* are updates / downgrades of one another).
|
|
|
|
*
|
|
|
|
* If this returns true, createInstance() will not run, so you should do all update steps in here.
|
|
|
|
* Otherwise, createInstance() is run as normal.
|
|
|
|
*/
|
|
|
|
virtual bool updateInstance() { return false; };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
|
|
|
*
|
|
|
|
* Returns whether the instance creation was successful (true) or not (false).
|
|
|
|
*/
|
|
|
|
virtual bool createInstance() { return false; };
|
|
|
|
|
2022-07-09 03:14:43 +05:30
|
|
|
QString getError() const { return m_error_message; }
|
|
|
|
|
2022-07-08 05:01:24 +05:30
|
|
|
protected:
|
2023-05-21 14:16:28 +05:30
|
|
|
void setError(const QString& message) { m_error_message = message; };
|
2022-07-08 05:01:24 +05:30
|
|
|
|
2022-08-01 04:59:12 +05:30
|
|
|
protected:
|
|
|
|
bool m_abort = false;
|
|
|
|
|
fix: move file deletion to the end of the instance update
This makes it harder for problems in the updating process to affect the
current instance. Network issues, for instance, will no longer put the
instance in an invalid state.
Still, a possible improvement to this would be passing that logic to
InstanceStaging instead, to be handled with the instance commiting
directly. However, as it is now, the code would become very spaguetti-y,
and given that the override operation in the commiting could also put
the instance into an invalid state, it seems to me that, in order to
fully error-proof this, we would need to do a copy operation on the
whole instance, in order to modify the copy, and only in the end
override everything an once with a rename. That also has the possibility
of corrupting the instance if done without super care, however, so I
think we may need to instead create an automatic backup system, with an
undo command of sorts, or something like that. This doesn't seem very
trivial though, so it'll probably need to wait until another PR. In the
meantime, the user is advised to always backup their instances before
doing this kind of action, as always.
What a long commit message o.O
Signed-off-by: flow <flowlnlnln@gmail.com>
2022-08-06 05:56:02 +05:30
|
|
|
QStringList m_files_to_remove;
|
|
|
|
|
2022-07-08 05:01:24 +05:30
|
|
|
private:
|
|
|
|
QString m_error_message;
|
2016-10-03 04:25:54 +05:30
|
|
|
};
|