diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-06-27 12:41:36 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-06-27 12:41:36 -0700 |
commit | 23b3711f96bd93171eebc401f983ccf0fb862772 (patch) | |
tree | ff2440ac0f26b5b2e75e5db05152360ae7010207 | |
parent | 904b128afe180a24d697723ae40325c0adc4d2ef (diff) | |
download | PrismLauncher-23b3711f96bd93171eebc401f983ccf0fb862772.tar.gz PrismLauncher-23b3711f96bd93171eebc401f983ccf0fb862772.tar.bz2 PrismLauncher-23b3711f96bd93171eebc401f983ccf0fb862772.zip |
fix(filesystem): track failed copies and clones
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
-rw-r--r-- | launcher/FileSystem.cpp | 9 | ||||
-rw-r--r-- | launcher/FileSystem.h | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 835ad925..0554cab8 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -36,6 +36,7 @@ */ #include "FileSystem.h" +#include <qpair.h> #include "BuildConfig.h" @@ -246,6 +247,7 @@ bool copy::operator()(const QString& offset, bool dryRun) { using copy_opts = fs::copy_options; m_copied = 0; // reset counter + m_failedPaths.clear(); // NOTE always deep copy on windows. the alternatives are too messy. #if defined Q_OS_WIN32 @@ -277,6 +279,9 @@ bool copy::operator()(const QString& offset, bool dryRun) qWarning() << "Failed to copy files:" << QString::fromStdString(err.message()); qDebug() << "Source file:" << src_path; qDebug() << "Destination file:" << dst_path; + m_failedPaths.append(dst_path); + emit copyFailed(relative_dst_path); + return; } m_copied++; emit fileCopied(relative_dst_path); @@ -1072,6 +1077,7 @@ bool clone::operator()(const QString& offset, bool dryRun) } m_cloned = 0; // reset counter + m_failedClones.clear(); auto src = PathCombine(m_src.absolutePath(), offset); auto dst = PathCombine(m_dst.absolutePath(), offset); @@ -1092,6 +1098,9 @@ bool clone::operator()(const QString& offset, bool dryRun) qDebug() << "Failed to clone files: error" << err.value() << "message" << QString::fromStdString(err.message()); qDebug() << "Source file:" << src_path; qDebug() << "Destination file:" << dst_path; + m_failedClones.append(qMakePair(src_path, dst_path)); + emit cloneFailed(src_path, dst_path); + return; } m_cloned++; emit fileCloned(src_path, dst_path); diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index cb581d0c..f8a82bae 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -43,6 +43,7 @@ #include <system_error> #include <QDir> +#include <QPair> #include <QFlags> #include <QLocalServer> #include <QObject> @@ -112,9 +113,12 @@ class copy : public QObject { bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); } int totalCopied() { return m_copied; } + int totalFailed() { return m_failedPaths.length(); } + QStringList failed() { return m_failedPaths; } signals: void fileCopied(const QString& relativeName); + void copyFailed(const QString& relativeName); // TODO: maybe add a "shouldCopy" signal in the future? private: @@ -127,6 +131,7 @@ class copy : public QObject { QDir m_src; QDir m_dst; int m_copied; + QStringList m_failedPaths; }; struct LinkPair { @@ -471,6 +476,9 @@ class clone : public QObject { bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); } int totalCloned() { return m_cloned; } + int totalFailed() { return m_failedClones.length(); } + + QList<QPair<QString, QString>> failed() { return m_failedClones; } signals: void fileCloned(const QString& src, const QString& dst); @@ -485,6 +493,7 @@ class clone : public QObject { QDir m_src; QDir m_dst; int m_cloned; + QList<QPair<QString, QString>> m_failedClones; }; /** |