summaryrefslogtreecommitdiff
path: root/src/installationmanager.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-06-01 17:40:15 +0200
committerMikaël Capelle <capelle.mikael@gmail.com>2020-06-01 17:40:15 +0200
commitaf0c0dc33e639f116aaa5c0ac4f2541a80106099 (patch)
treeb390933fcff6168c1dad90ab57dd73d66fb4db9a /src/installationmanager.cpp
parent046af63dd55ee4b04d79cb2188f169bd8292aa19 (diff)
Correct handling of 7z errors.
Diffstat (limited to 'src/installationmanager.cpp')
-rw-r--r--src/installationmanager.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index a60e60eb..639dc88a 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -158,18 +158,12 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool
QString errorMessage;
// The callbacks:
- ProgressCallback progressCallback = [&progress, installationProgress, this](float p) {
- progress = static_cast<int>(p * 100.0);
-
- if (installationProgress->wasCanceled()) {
- m_ArchiveHandler->cancel();
- installationProgress->reset();
- }
- };
+ ProgressCallback progressCallback = [&progress](float p) { progress = static_cast<int>(p * 100.0); };
FileChangeCallback fileChangeCallback = [&progressFile](std::wstring const& file) {
progressFile = QString::fromStdWString(file);
};
ErrorCallback errorCallback = [&errorMessage, this](std::wstring const& message) {
+ m_ArchiveHandler->cancel();
errorMessage = QString::fromStdWString(message);
};
@@ -182,7 +176,13 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool
errorCallback
);
});
+
+ // Wait for the extraction to complete (or be cancelled):
do {
+ if (installationProgress->wasCanceled()) {
+ m_ArchiveHandler->cancel();
+ installationProgress->reset();
+ }
if (progress != installationProgress->value()) {
installationProgress->setValue(progress);
}
@@ -191,7 +191,8 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool
}
QCoreApplication::processEvents();
} while (!future.isFinished());
- log::debug("Extraction took {:.3f}s.", std::chrono::duration<double>(std::chrono::system_clock::now() - start).count());
+
+ // Check the result:
if (!future.result()) {
if (m_ArchiveHandler->getLastError() == Archive::Error::ERROR_EXTRACT_CANCELLED) {
if (!errorMessage.isEmpty()) {
@@ -206,6 +207,8 @@ bool InstallationManager::extractFiles(QString extractPath, QString title, bool
}
}
+ log::debug("Extraction took {:.3f}s.", std::chrono::duration<double>(std::chrono::system_clock::now() - start).count());
+
return true;
}