aboutsummaryrefslogtreecommitdiff
path: root/api/logic/modplatform/technic/SingleZipPackInstallTask.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2021-07-06 22:01:33 +0200
committerGitHub <noreply@github.com>2021-07-06 22:01:33 +0200
commitdf1d3dbae2d11557e5b4d2ab9c5c1333a8af799e (patch)
tree5ce39c5d8689a32c04340c3e9af5a18ae8c350d0 /api/logic/modplatform/technic/SingleZipPackInstallTask.cpp
parent417994735a4823782f0f2304695347a13eed9a1d (diff)
parent220971fadd8cc2def071818c17cda14bad0f6f45 (diff)
downloadPrismLauncher-df1d3dbae2d11557e5b4d2ab9c5c1333a8af799e.tar.gz
PrismLauncher-df1d3dbae2d11557e5b4d2ab9c5c1333a8af799e.tar.bz2
PrismLauncher-df1d3dbae2d11557e5b4d2ab9c5c1333a8af799e.zip
Merge pull request #3925 from jamierocks/fix-1949
GH-1949 Allow modpack downloads to be aborted
Diffstat (limited to 'api/logic/modplatform/technic/SingleZipPackInstallTask.cpp')
-rw-r--r--api/logic/modplatform/technic/SingleZipPackInstallTask.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/api/logic/modplatform/technic/SingleZipPackInstallTask.cpp b/api/logic/modplatform/technic/SingleZipPackInstallTask.cpp
index 96e1804d..dbce8e53 100644
--- a/api/logic/modplatform/technic/SingleZipPackInstallTask.cpp
+++ b/api/logic/modplatform/technic/SingleZipPackInstallTask.cpp
@@ -28,6 +28,14 @@ Technic::SingleZipPackInstallTask::SingleZipPackInstallTask(const QUrl &sourceUr
m_minecraftVersion = minecraftVersion;
}
+bool Technic::SingleZipPackInstallTask::abort() {
+ if(m_abortable)
+ {
+ return m_filesNetJob->abort();
+ }
+ return false;
+}
+
void Technic::SingleZipPackInstallTask::executeTask()
{
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
@@ -47,6 +55,8 @@ void Technic::SingleZipPackInstallTask::executeTask()
void Technic::SingleZipPackInstallTask::downloadSucceeded()
{
+ m_abortable = false;
+
setStatus(tr("Extracting modpack"));
QDir extractDir(FS::PathCombine(m_stagingPath, ".minecraft"));
qDebug() << "Attempting to create instance from" << m_archivePath;
@@ -67,12 +77,14 @@ void Technic::SingleZipPackInstallTask::downloadSucceeded()
void Technic::SingleZipPackInstallTask::downloadFailed(QString reason)
{
+ m_abortable = false;
emitFailed(reason);
m_filesNetJob.reset();
}
void Technic::SingleZipPackInstallTask::downloadProgressChanged(qint64 current, qint64 total)
{
+ m_abortable = true;
setProgress(current / 2, total);
}