fix: copy needs to overwrite
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
400a2f7201
commit
cb7ff81ade
@ -297,6 +297,9 @@ bool copy::operator()(const QString& offset, bool dryRun)
|
|||||||
if (!m_followSymlinks)
|
if (!m_followSymlinks)
|
||||||
opt |= copy_opts::copy_symlinks;
|
opt |= copy_opts::copy_symlinks;
|
||||||
|
|
||||||
|
if (m_overwrite)
|
||||||
|
opt |= copy_opts::overwrite_existing;
|
||||||
|
|
||||||
// Function that'll do the actual copying
|
// Function that'll do the actual copying
|
||||||
auto copy_file = [&](QString src_path, QString relative_dst_path) {
|
auto copy_file = [&](QString src_path, QString relative_dst_path) {
|
||||||
if (m_matcher && (m_matcher->matches(relative_dst_path) != m_whitelist))
|
if (m_matcher && (m_matcher->matches(relative_dst_path) != m_whitelist))
|
||||||
|
@ -120,6 +120,11 @@ class copy : public QObject {
|
|||||||
m_whitelist = whitelist;
|
m_whitelist = whitelist;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
copy& overwrite(const bool overwrite)
|
||||||
|
{
|
||||||
|
m_overwrite = overwrite;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
|
bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
|
||||||
|
|
||||||
@ -136,6 +141,7 @@ class copy : public QObject {
|
|||||||
bool m_followSymlinks = true;
|
bool m_followSymlinks = true;
|
||||||
const IPathMatcher* m_matcher = nullptr;
|
const IPathMatcher* m_matcher = nullptr;
|
||||||
bool m_whitelist = false;
|
bool m_whitelist = false;
|
||||||
|
bool m_overwrite = false;
|
||||||
QDir m_src;
|
QDir m_src;
|
||||||
QDir m_dst;
|
QDir m_dst;
|
||||||
int m_copied;
|
int m_copied;
|
||||||
|
@ -672,7 +672,7 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target)
|
|||||||
auto install_path = FS::PathCombine(target.absolutePath(), rel_path);
|
auto install_path = FS::PathCombine(target.absolutePath(), rel_path);
|
||||||
logUpdate(tr("Installing %1 from %2").arg(install_path).arg(to_install_file));
|
logUpdate(tr("Installing %1 from %2").arg(install_path).arg(to_install_file));
|
||||||
FS::ensureFilePathExists(install_path);
|
FS::ensureFilePathExists(install_path);
|
||||||
auto result = FS::copy(to_install_file, install_path)();
|
auto result = FS::copy(to_install_file, install_path).overwrite(true)();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
error = true;
|
error = true;
|
||||||
logUpdate(tr("Failed copy %1 to %2").arg(to_install_file).arg(install_path));
|
logUpdate(tr("Failed copy %1 to %2").arg(to_install_file).arg(install_path));
|
||||||
@ -686,11 +686,11 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target)
|
|||||||
if (error) {
|
if (error) {
|
||||||
logUpdate(tr("There were errors installing the update."));
|
logUpdate(tr("There were errors installing the update."));
|
||||||
auto fail_marker = FS::PathCombine(m_dataPath, ".prism_launcher_update.fail");
|
auto fail_marker = FS::PathCombine(m_dataPath, ".prism_launcher_update.fail");
|
||||||
FS::copy(m_updateLogPath, fail_marker)();
|
FS::copy(m_updateLogPath, fail_marker).overwrite(true)();
|
||||||
} else {
|
} else {
|
||||||
logUpdate(tr("Update succeed."));
|
logUpdate(tr("Update succeed."));
|
||||||
auto success_marker = FS::PathCombine(m_dataPath, ".prism_launcher_update.success");
|
auto success_marker = FS::PathCombine(m_dataPath, ".prism_launcher_update.success");
|
||||||
FS::copy(m_updateLogPath, success_marker)();
|
FS::copy(m_updateLogPath, success_marker).overwrite(true)();
|
||||||
}
|
}
|
||||||
auto update_lock_path = FS::PathCombine(m_dataPath, ".prism_launcher_update.lock");
|
auto update_lock_path = FS::PathCombine(m_dataPath, ".prism_launcher_update.lock");
|
||||||
FS::deletePath(update_lock_path);
|
FS::deletePath(update_lock_path);
|
||||||
@ -1078,7 +1078,7 @@ void PrismUpdaterApp::backupAppDir()
|
|||||||
auto bak_path = FS::PathCombine(backup_dir, rel_path);
|
auto bak_path = FS::PathCombine(backup_dir, rel_path);
|
||||||
logUpdate(tr("Backing up and then removing %1").arg(to_bak_file));
|
logUpdate(tr("Backing up and then removing %1").arg(to_bak_file));
|
||||||
FS::ensureFilePathExists(bak_path);
|
FS::ensureFilePathExists(bak_path);
|
||||||
auto result = FS::copy(to_bak_file, bak_path)();
|
auto result = FS::copy(to_bak_file, bak_path).overwrite(true)();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
logUpdate(tr("Failed to backup %1 to %2").arg(to_bak_file).arg(bak_path));
|
logUpdate(tr("Failed to backup %1 to %2").arg(to_bak_file).arg(bak_path));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user