GH-1927 Add more specific task status logging
* Tasks are now described by class name and object name (or memory address). * Tasks starts are logged. * Aborted tasks are now treated just as the other cases.
This commit is contained in:
parent
fbeceaa98c
commit
e5b4b5d295
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
typedef std::shared_ptr<class SkinUpload> SkinUploadPtr;
|
typedef std::shared_ptr<class SkinUpload> SkinUploadPtr;
|
||||||
|
|
||||||
class MULTIMC_LOGIC_EXPORT SkinUpload : public Task\
|
class MULTIMC_LOGIC_EXPORT SkinUpload : public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Model
|
enum Model
|
||||||
{
|
{
|
||||||
|
@ -95,12 +95,11 @@ shared_qobject_ptr<Task> LegacyInstance::createUpdateTask()
|
|||||||
return shared_qobject_ptr<Task>(new LegacyUpdate(this, this));
|
return shared_qobject_ptr<Task>(new LegacyUpdate(this, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
|
class LegacyJarModTask : public Task
|
||||||
{
|
{
|
||||||
class JarModTask : public Task
|
Q_OBJECT
|
||||||
{
|
public:
|
||||||
public:
|
explicit LegacyJarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst)
|
||||||
explicit JarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual void executeTask()
|
virtual void executeTask()
|
||||||
@ -172,8 +171,11 @@ std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
|
|||||||
|
|
||||||
}
|
}
|
||||||
std::shared_ptr<LegacyInstance> m_inst;
|
std::shared_ptr<LegacyInstance> m_inst;
|
||||||
};
|
};
|
||||||
return std::make_shared<JarModTask>(std::dynamic_pointer_cast<LegacyInstance>(shared_from_this()));
|
|
||||||
|
std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
|
||||||
|
{
|
||||||
|
return std::make_shared<LegacyJarModTask>(std::dynamic_pointer_cast<LegacyInstance>(shared_from_this()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LegacyInstance::createLaunchScript(AuthSessionPtr session)
|
QString LegacyInstance::createLaunchScript(AuthSessionPtr session)
|
||||||
@ -515,3 +517,5 @@ QStringList LegacyInstance::processMinecraftArgs(AuthSessionPtr account) const
|
|||||||
out.append(account->session);
|
out.append(account->session);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "LegacyInstance.moc"
|
||||||
|
@ -368,12 +368,10 @@ std::shared_ptr<LaunchStep> OneSixInstance::createMainLaunchStep(LaunchTask * pa
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class JarModTask : public Task
|
||||||
std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
|
|
||||||
{
|
{
|
||||||
class JarModTask : public Task
|
Q_OBJECT
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
explicit JarModTask(std::shared_ptr<OneSixInstance> inst) : Task(nullptr), m_inst(inst)
|
explicit JarModTask(std::shared_ptr<OneSixInstance> inst) : Task(nullptr), m_inst(inst)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -414,7 +412,10 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
std::shared_ptr<OneSixInstance> m_inst;
|
std::shared_ptr<OneSixInstance> m_inst;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
|
||||||
|
{
|
||||||
return std::make_shared<JarModTask>(std::dynamic_pointer_cast<OneSixInstance>(shared_from_this()));
|
return std::make_shared<JarModTask>(std::dynamic_pointer_cast<OneSixInstance>(shared_from_this()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,3 +697,5 @@ QStringList OneSixInstance::getNativeJars() const
|
|||||||
m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||||
return nativeJars;
|
return nativeJars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "OneSixInstance.moc"
|
||||||
|
@ -142,11 +142,21 @@ void OneSixUpdate::next()
|
|||||||
|
|
||||||
void OneSixUpdate::subtaskSucceeded()
|
void OneSixUpdate::subtaskSucceeded()
|
||||||
{
|
{
|
||||||
|
if(isFinished())
|
||||||
|
{
|
||||||
|
qCritical() << "OneSixUpdate: Subtask" << sender() << "succeeded, but work was already done!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::subtaskFailed(QString error)
|
void OneSixUpdate::subtaskFailed(QString error)
|
||||||
{
|
{
|
||||||
|
if(isFinished())
|
||||||
|
{
|
||||||
|
qCritical() << "OneSixUpdate: Subtask" << sender() << "failed, but work was already done!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
emitFailed(error);
|
emitFailed(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ class OneSixInstance;
|
|||||||
|
|
||||||
class AssetUpdateTask : public Task
|
class AssetUpdateTask : public Task
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AssetUpdateTask(OneSixInstance * inst);
|
AssetUpdateTask(OneSixInstance * inst);
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
@ -5,6 +5,7 @@ class OneSixInstance;
|
|||||||
|
|
||||||
class FMLLibrariesTask : public Task
|
class FMLLibrariesTask : public Task
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FMLLibrariesTask(OneSixInstance * inst);
|
FMLLibrariesTask(OneSixInstance * inst);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
FoldersTask::FoldersTask(OneSixInstance * inst)
|
FoldersTask::FoldersTask(OneSixInstance * inst)
|
||||||
|
:Task()
|
||||||
{
|
{
|
||||||
m_inst = inst;
|
m_inst = inst;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
class OneSixInstance;
|
class OneSixInstance;
|
||||||
class FoldersTask : public Task
|
class FoldersTask : public Task
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FoldersTask(OneSixInstance * inst);
|
FoldersTask(OneSixInstance * inst);
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
@ -5,6 +5,7 @@ class OneSixInstance;
|
|||||||
|
|
||||||
class LibrariesTask : public Task
|
class LibrariesTask : public Task
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LibrariesTask(OneSixInstance * inst);
|
LibrariesTask(OneSixInstance * inst);
|
||||||
|
|
||||||
|
@ -94,7 +94,6 @@ void NetJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTotal)
|
|||||||
|
|
||||||
void NetJob::executeTask()
|
void NetJob::executeTask()
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name.toLocal8Bit() << " started.";
|
|
||||||
// hack that delays early failures so they can be caught easier
|
// hack that delays early failures so they can be caught easier
|
||||||
QMetaObject::invokeMethod(this, "startMoreParts", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "startMoreParts", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
@ -114,18 +113,15 @@ void NetJob::startMoreParts()
|
|||||||
{
|
{
|
||||||
if(!m_failed.size())
|
if(!m_failed.size())
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name << "succeeded.";
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
else if(m_aborted)
|
else if(m_aborted)
|
||||||
{
|
{
|
||||||
qDebug() << m_job_name << "aborted.";
|
emitAborted();
|
||||||
emitFailed(tr("Job '%1' aborted.").arg(m_job_name));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical() << m_job_name << "failed.";
|
emitFailed(tr("Job '%1' failed to process:\n%2").arg(objectName()).arg(getFailedFiles().join("\n")));
|
||||||
emitFailed(tr("Job '%1' failed to process:\n%2").arg(m_job_name).arg(getFailedFiles().join("\n")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,10 @@ class MULTIMC_LOGIC_EXPORT NetJob : public Task
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NetJob(QString job_name) : Task(), m_job_name(job_name) {}
|
explicit NetJob(QString job_name) : Task()
|
||||||
|
{
|
||||||
|
setObjectName(job_name);
|
||||||
|
}
|
||||||
virtual ~NetJob() {}
|
virtual ~NetJob() {}
|
||||||
|
|
||||||
bool addNetAction(NetActionPtr action);
|
bool addNetAction(NetActionPtr action);
|
||||||
@ -77,7 +80,6 @@ private:
|
|||||||
qint64 total_progress = 1;
|
qint64 total_progress = 1;
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
};
|
};
|
||||||
QString m_job_name;
|
|
||||||
QList<NetActionPtr> downloads;
|
QList<NetActionPtr> downloads;
|
||||||
QList<part_info> parts_progress;
|
QList<part_info> parts_progress;
|
||||||
QQueue<int> m_todo;
|
QQueue<int> m_todo;
|
||||||
|
@ -41,31 +41,79 @@ void Task::start()
|
|||||||
{
|
{
|
||||||
m_running = true;
|
m_running = true;
|
||||||
emit started();
|
emit started();
|
||||||
|
qDebug() << "Task" << describe() << "started";
|
||||||
executeTask();
|
executeTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::emitFailed(QString reason)
|
void Task::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
|
// Don't fail twice.
|
||||||
|
if (!m_running)
|
||||||
|
{
|
||||||
|
qCritical() << "Task" << describe() << "failed while not running!!!!: " << reason;
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
m_succeeded = false;
|
m_succeeded = false;
|
||||||
m_failReason = reason;
|
m_failReason = reason;
|
||||||
qCritical() << "Task failed: " << reason;
|
qCritical() << "Task" << describe() << "failed: " << reason;
|
||||||
emit failed(reason);
|
emit failed(reason);
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Task::emitAborted()
|
||||||
|
{
|
||||||
|
// Don't abort twice.
|
||||||
|
if (!m_running)
|
||||||
|
{
|
||||||
|
qCritical() << "Task" << describe() << "aborted while not running!!!!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_running = false;
|
||||||
|
m_finished = true;
|
||||||
|
m_succeeded = false;
|
||||||
|
m_failReason = "Aborted.";
|
||||||
|
qDebug() << "Task" << describe() << "aborted.";
|
||||||
|
emit failed(m_failReason);
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
void Task::emitSucceeded()
|
void Task::emitSucceeded()
|
||||||
{
|
{
|
||||||
if (!m_running) { return; } // Don't succeed twice.
|
// Don't succeed twice.
|
||||||
|
if (!m_running)
|
||||||
|
{
|
||||||
|
qCritical() << "Task" << describe() << "succeeded while not running!!!!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
m_succeeded = true;
|
m_succeeded = true;
|
||||||
qDebug() << "Task succeeded";
|
qDebug() << "Task" << describe() << "succeeded";
|
||||||
emit succeeded();
|
emit succeeded();
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Task::describe()
|
||||||
|
{
|
||||||
|
QString outStr;
|
||||||
|
QTextStream out(&outStr);
|
||||||
|
out << metaObject()->className() << QChar('(');
|
||||||
|
auto name = objectName();
|
||||||
|
if(name.isEmpty())
|
||||||
|
{
|
||||||
|
out << QString("0x%1").arg((quintptr)this, 0, 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out << name;
|
||||||
|
}
|
||||||
|
out << QChar(')');
|
||||||
|
out.flush();
|
||||||
|
return outStr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Task::isRunning() const
|
bool Task::isRunning() const
|
||||||
{
|
{
|
||||||
return m_running;
|
return m_running;
|
||||||
|
@ -54,6 +54,9 @@ public:
|
|||||||
return m_progressTotal;
|
return m_progressTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString describe();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
void progress(qint64 current, qint64 total);
|
void progress(qint64 current, qint64 total);
|
||||||
@ -71,6 +74,7 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void emitSucceeded();
|
virtual void emitSucceeded();
|
||||||
|
virtual void emitAborted();
|
||||||
virtual void emitFailed(QString reason);
|
virtual void emitFailed(QString reason);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user