updated portable update
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
606c12ffeb
commit
742384909f
@ -27,20 +27,20 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QAccessible>
|
|
||||||
#include <QCommandLineParser>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QAccessible>
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QProgressDialog>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <sys.h>
|
#include <sys.h>
|
||||||
#include <QProgressDialog>
|
|
||||||
|
|
||||||
#if defined Q_OS_WIN32
|
#if defined Q_OS_WIN32
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
@ -660,28 +660,42 @@ void PrismUpdaterApp::moveAndFinishUpdate(QDir target)
|
|||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
QProgressDialog progress(tr("Backing up install at %1").arg(m_rootPath), "", 0, file_list.length());
|
QProgressDialog progress(tr("Installing from %1").arg(m_rootPath), "", 0, file_list.length());
|
||||||
progress.setCancelButton(nullptr);
|
progress.setCancelButton(nullptr);
|
||||||
progress.setMinimumWidth(400);
|
progress.setMinimumWidth(400);
|
||||||
progress.adjustSize();
|
progress.adjustSize();
|
||||||
progress.show();
|
progress.show();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
int i = 0;
|
logUpdate(tr("Installing from %1").arg(m_rootPath));
|
||||||
for (auto glob : file_list) {
|
|
||||||
QDirIterator iter(m_rootPath, QStringList({ glob }), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
auto copy = [this, app_dir, target](QString to_install_file) {
|
||||||
progress.setValue(i);
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
auto to_install_file = iter.next();
|
|
||||||
auto rel_path = app_dir.relativeFilePath(to_install_file);
|
auto rel_path = app_dir.relativeFilePath(to_install_file);
|
||||||
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).overwrite(true)();
|
auto result = FS::copy(to_install_file, install_path).overwrite(true)();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
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));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (auto glob : file_list) {
|
||||||
|
QDirIterator iter(m_rootPath, QStringList({ glob }), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
progress.setValue(i);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
if (!iter.hasNext() && !glob.isEmpty()) {
|
||||||
|
if (auto file_info = QFileInfo(FS::PathCombine(m_rootPath, glob)); file_info.exists()) {
|
||||||
|
error |= copy(file_info.absoluteFilePath());
|
||||||
|
} else {
|
||||||
|
logUpdate(tr("File doesn't exist, ignoring: %1").arg(FS::PathCombine(m_rootPath, glob)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
error |= copy(iter.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@ -1124,13 +1138,10 @@ void PrismUpdaterApp::backupAppDir()
|
|||||||
progress.adjustSize();
|
progress.adjustSize();
|
||||||
progress.show();
|
progress.show();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
int i = 0;
|
|
||||||
for (auto glob : file_list) {
|
logUpdate(tr("Backing up install at %1").arg(m_rootPath));
|
||||||
QDirIterator iter(app_dir.absolutePath(), QStringList({ glob }), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
|
||||||
progress.setValue(i);
|
auto copy = [this, app_dir, backup_dir](QString to_bak_file) {
|
||||||
QCoreApplication::processEvents();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
auto to_bak_file = iter.next();
|
|
||||||
auto rel_path = app_dir.relativeFilePath(to_bak_file);
|
auto rel_path = app_dir.relativeFilePath(to_bak_file);
|
||||||
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));
|
||||||
@ -1142,6 +1153,23 @@ void PrismUpdaterApp::backupAppDir()
|
|||||||
if (!FS::deletePath(to_bak_file))
|
if (!FS::deletePath(to_bak_file))
|
||||||
logUpdate(tr("Failed to remove %1").arg(to_bak_file));
|
logUpdate(tr("Failed to remove %1").arg(to_bak_file));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (auto glob : file_list) {
|
||||||
|
QDirIterator iter(app_dir.absolutePath(), QStringList({ glob }), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
progress.setValue(i);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
if (!iter.hasNext() && !glob.isEmpty()) {
|
||||||
|
if (auto file_info = QFileInfo(FS::PathCombine(m_rootPath, glob)); file_info.exists()) {
|
||||||
|
copy(file_info.absoluteFilePath());
|
||||||
|
} else {
|
||||||
|
logUpdate(tr("File doesn't exist, ignoring: %1").arg(FS::PathCombine(m_rootPath, glob)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
copy(iter.next());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user