Skip to content

Commit 7747b64

Browse files
committed
Fix libarchive utf8 bug on old versions
1 parent 350c76d commit 7747b64

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ int main(int argc,
110110
// Prepare logger
111111
Log::clear();
112112
Log::information("Application version: " + QString(APP_VERSION_FULL));
113+
Log::information("Qt library version: " + QString(qVersion()));
114+
115+
113116
Log::debug("Launched by system session manager: " + QString(qApp->isSessionRestored() ? "yes" : "no"));
114117

115118
QFile id("/var/lib/dbus/machine-id");

src/subprojects/AutoEqIntegration/AeqSelector.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void AeqSelector::forceManageMode()
7373
}
7474

7575
void AeqSelector::showEvent(QShowEvent *ev)
76-
{
76+
{
7777
if(!pkgManager->isPackageInstalled())
7878
{
7979
this->setEnabled(false);
@@ -84,9 +84,10 @@ void AeqSelector::showEvent(QShowEvent *ev)
8484
"Do you want to continue and enable this feature?",
8585
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
8686

87+
auto cancel = [this]{ QTimer::singleShot(250, this, &QDialog::reject); };
8788
if(res == QMessageBox::Cancel)
8889
{
89-
this->reject();
90+
cancel();
9091
return;
9192
}
9293

@@ -96,15 +97,15 @@ void AeqSelector::showEvent(QShowEvent *ev)
9697
{
9798
this->setEnabled(true);
9899
updateDatabaseInfo();
99-
}).fail([this](){
100-
this->reject();
100+
}).fail([cancel](){
101+
cancel();
101102
return;
102103
});
103104

104-
}).fail([this](const HttpException& ex){
105+
}).fail([this, cancel](const HttpException& ex){
105106
QMessageBox::critical(this, "Failed to retrieve version information", QString("Failed to retrieve package information from the remote repository:\n\n"
106107
"Status code: %0\nReason: %1").arg(ex.statusCode()).arg(ex.reasonPhrase()));
107-
this->reject();
108+
cancel();
108109
return;
109110
});
110111
}

src/subprojects/AutoEqIntegration/GzipDownloader.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool GzipDownloader::start(QNetworkReply *reply, QDir _extractionPath)
1515
}
1616

1717
downloadedFile.setFileName(TMP_DIR + QDateTime::currentDateTime().toString("yyyy_MM_dd_hhmmss_zzz") + ".tar.gz");
18-
if(!downloadedFile.open(QIODevice::ReadWrite))
18+
if(!downloadedFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered))
1919
{
2020
return false;
2121
}
@@ -25,6 +25,8 @@ bool GzipDownloader::start(QNetworkReply *reply, QDir _extractionPath)
2525
connect(networkReply, &QIODevice::readyRead, this, &GzipDownloader::onDataAvailable);
2626
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
2727
connect(networkReply, &QNetworkReply::errorOccurred, this, &GzipDownloader::onErrorOccurred);
28+
#else
29+
connect(networkReply, qOverload<QNetworkReply::NetworkError>(&QNetworkReply::error), this, &GzipDownloader::onErrorOccurred);
2830
#endif
2931
connect(networkReply, &QNetworkReply::downloadProgress, this, &GzipDownloader::downloadProgressUpdated);
3032
connect(networkReply, &QNetworkReply::finished, this, &GzipDownloader::onArchiveReady);
@@ -46,9 +48,11 @@ bool GzipDownloader::isActive()
4648
return networkReply;
4749
}
4850

51+
static int bytes = 0;
4952
void GzipDownloader::onDataAvailable()
5053
{
51-
downloadedFile.write(networkReply->readAll());
54+
auto dat = networkReply->readAll();
55+
downloadedFile.write(dat);
5256
}
5357

5458
void GzipDownloader::onArchiveReady()
@@ -60,7 +64,9 @@ void GzipDownloader::onArchiveReady()
6064
}
6165
else
6266
{
63-
downloadedFile.write(networkReply->readAll());
67+
auto dat = networkReply->readAll();
68+
downloadedFile.write(dat);
69+
downloadedFile.close();
6470

6571
emit decompressionStarted();
6672

src/subprojects/AutoEqIntegration/Untar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Untar
5353

5454
const char* currentFile = archive_entry_pathname(entry);
5555
const QString fullOutputPath = outputPath.path() + QDir::separator() + currentFile;
56-
archive_entry_set_pathname_utf8(entry, fullOutputPath.toUtf8().constData());
56+
archive_entry_set_pathname(entry, fullOutputPath.toLatin1().constData());
5757

5858
r = archive_write_header(ext, entry);
5959
if (r < ARCHIVE_OK)

0 commit comments

Comments
 (0)