Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ytobi's aria2 fixes #4

Open
wants to merge 16 commits into
base: aria2
Choose a base branch
from
Open
5 changes: 2 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build linux x86_64:

# Post-processing
- mv launcher/bin .
- upx --lzma -9 --force bin/launcher
- upx -9 --force bin/launcher
artifacts:
paths:
- bin/
Expand All @@ -64,7 +64,7 @@ build windows i686:

# Post-processing
- mv launcher/bin .
- upx --lzma -9 --force bin/launcher.exe
- upx -9 --force bin/launcher.exe
artifacts:
paths:
- bin/
Expand All @@ -87,7 +87,6 @@ deploy linux x86_64:
- artifact/

deploy windows i686:
image: ubuntu
stage: deploy
dependencies:
- build windows i686
Expand Down
8 changes: 4 additions & 4 deletions launcher/ci.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/launcher/launcher.pro b/launcher/launcher.pro
index 2484f07..f7940f2 100644
index 1f2bf6c..fbd06ad 100644
--- a/launcher/launcher.pro
+++ b/launcher/launcher.pro
@@ -59,7 +59,7 @@ RESOURCES += \
@@ -59,7 +59,6 @@ RESOURCES += \
# For QArchive
QT += concurrent

-LIBS += ../libs/QArchive/libQArchive.a -larchive -lbz2 -llzma -llz4 -lz -lzstd -lnettle -lexpat -lxml2
+LIBS += ../libs/QArchive/release/libQArchive.a -larchive -lbz2 -llzma -llz4 -lz -lzstd -lnettle -lexpat -lxml2 /opt/mxe/usr/i686-w64-mingw32.static.posix/lib/liblzma.a
win32:LIBS += -lbcrypt -liconv
-win32:LIBS += -lbcrypt -liconv
+LIBS += ../libs/QArchive/release/libQArchive.a -larchive -lnettle -lxml2

INCLUDEPATH += ../libs/QArchive ../libs/QArchive/include
5 changes: 2 additions & 3 deletions launcher/launcher.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TEMPLATE = app

DESTDIR = $$PWD/bin

VERSION = 1.2.2
VERSION = 1.3.0
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

RC_ICONS = logo.ico
Expand Down Expand Up @@ -61,7 +61,6 @@ RESOURCES += \
# For QArchive
QT += concurrent

LIBS += ../libs/QArchive/libQArchive.a -larchive -lbz2 -llzma -llz4 -lz -lzstd -lnettle -lexpat -lxml2
win32:LIBS += -lbcrypt -liconv
LIBS += ../libs/QArchive/release/libQArchive.a -larchive -lnettle -lxml2

INCLUDEPATH += ../libs/QArchive ../libs/QArchive/include
3 changes: 2 additions & 1 deletion launcher/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QNetworkReply>

#include <QCoreApplication>
#include <QSettings>
#include <QFile>
#include <QJsonDocument>
Expand Down Expand Up @@ -98,7 +99,7 @@ void MainWindow::play() {
QString gamePath = installPath.filePath(versionInfo.value("program/executable").toString());
qDebug() << "Starting" << gamePath;
if (game.startDetached(gamePath, {}, installPath.absolutePath())) {
this->close();
QCoreApplication::quit();
} else {
QMessageBox::critical(this, "Error Starting Game", tr("Error starting %1: %2").arg(gamePath, game.errorString()));
}
Expand Down
6 changes: 3 additions & 3 deletions launcher/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <QtDebug>

const std::map<const QString, const QVariant> Options::defaultOptions = {
{"path", "."},
{"repos/program", "https://s3.wasabisys.com/ao-manifests/program_${os}_${arch}.json"},
{"repos/assets", "https://s3.wasabisys.com/ao-manifests/assets.json"},
{"path", "client"},
{"repos/program", "https://server.raidensnakesden.net/program_${os}_${arch}.json"},
{"repos/assets", "https://server.raidensnakesden.net/assets.json"},
{"checkOnLaunch", Qt::CheckState::Checked},
{"version", APP_VERSION}
};
Expand Down
31 changes: 17 additions & 14 deletions launcher/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,13 @@ void Updater::taskDownload(QDir &installDir, const QUrl &url, const QString &has
}

if (!hash.isEmpty()) {
QCryptographicHash sha1(QCryptographicHash::Sha1);
sha1.addData(&file);
if (sha1.result().toHex() == hash) {
QCryptographicHash sha256(QCryptographicHash::Sha256);
sha256.addData(&file);
if (sha256.result().toHex() == hash) {
skipDownload = true;
} else {
qWarning() << "checksum mismatch: expected" << hash
<< "but got" << sha1.result().toHex();
<< "but got" << sha256.result().toHex();
}
}

Expand Down Expand Up @@ -467,11 +467,11 @@ void Updater::taskDownload(QDir &installDir, const QUrl &url, const QString &has

// Calculate SHA-1 checksum of file
if (!hash.isEmpty()) {
QCryptographicHash sha1(QCryptographicHash::Sha1);
sha1.addData(&file);
if (sha1.result().toHex() != hash) {
QCryptographicHash sha256(QCryptographicHash::Sha256);
sha256.addData(&file);
if (sha256.result().toHex() != hash) {
qCritical() << "checksum: expected" << hash
<< "but got" << sha1.result().toHex();
<< "but got" << sha256.result().toHex();
throw RuntimeError(tr("Checksum of file %1 was invalid.")
.arg(url.toDisplayString()));
}
Expand All @@ -493,12 +493,15 @@ void Updater::taskDownload(QDir &installDir, const QUrl &url, const QString &has
// (Yeah, we're gonna do this crappy trick again...)
eventLoop.reset(new QEventLoop());
QArchive::DiskExtractor extractor(filename, installDir.path(), this, false);
// Note. The parmeters of the signal QArchive::DiskExtractor::error do not match the slot.
// QArchive::DiskExtractor::error emits short code only
QObject::connect(&extractor, &QArchive::DiskExtractor::error,
[&](short code, const QString &file) {
error = true;
errorMsg = file;
errorCode = code;
qCritical() << "Error extracting" << file << "- code" << code;
[&](short code) {
const QString file("Unknown file");
error = true;
errorMsg = file;
errorCode = code;
qCritical() << "Error extracting" << file << "- code" << code;
Comment on lines +499 to +504
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in this signal's signature is due to a major version change in QArchive that apparently was applied to this branch. I would be careful because I have not tested that new version.

emit eventLoop->quit();
});
QObject::connect(&extractor, &QArchive::DiskExtractor::progress,
Expand Down Expand Up @@ -550,7 +553,7 @@ void Updater::taskDelete(QDir &installDir, const QStringList &targets) {
if (!fileInfo.canonicalFilePath().startsWith(installDir.canonicalPath())) {
qWarning() << target << ": ignoring invalid path!";
} else {
QFile::remove(target);
QFile::remove(installDir.filePath(target));
}

completed++;
Expand Down