Fixed archive java download

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-03-21 00:42:04 +02:00
parent 1c809f0fb1
commit ab7fc2e46c
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
2 changed files with 10 additions and 2 deletions

View File

@ -510,6 +510,10 @@ bool ExportToZipTask::abort()
void ExtractZipTask::executeTask() void ExtractZipTask::executeTask()
{ {
if (!m_input->isOpen() && !m_input->open(QuaZip::mdUnzip)) {
emitFailed(tr("Unable to open supplied zip file."));
return;
}
m_zip_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return extractZip(); }); m_zip_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return extractZip(); });
connect(&m_zip_watcher, &QFutureWatcher<ZipResult>::finished, this, &ExtractZipTask::finish); connect(&m_zip_watcher, &QFutureWatcher<ZipResult>::finished, this, &ExtractZipTask::finish);
m_zip_watcher.setFuture(m_zip_future); m_zip_watcher.setFuture(m_zip_future);

View File

@ -35,7 +35,7 @@ void ArchiveDownloadTask::executeTask()
// JRE found ! download the zip // JRE found ! download the zip
setStatus(tr("Downloading Java")); setStatus(tr("Downloading Java"));
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("java", m_url.toLocalFile()); MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("java", m_url.fileName());
auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network()); auto download = makeShared<NetJob>(QString("JRE::DownloadJava"), APPLICATION->network());
auto action = Net::Download::makeCached(m_url, entry); auto action = Net::Download::makeCached(m_url, entry);
@ -70,12 +70,16 @@ void ArchiveDownloadTask::extractJava(QString input)
{ {
setStatus(tr("Extracting java")); setStatus(tr("Extracting java"));
auto zip = std::make_shared<QuaZip>(input); auto zip = std::make_shared<QuaZip>(input);
if (!zip->open(QuaZip::mdUnzip)) {
emitFailed(tr("Unable to open supplied zip file."));
return;
}
auto files = zip->getFileNameList(); auto files = zip->getFileNameList();
if (files.isEmpty()) { if (files.isEmpty()) {
emitFailed("Empty archive"); emitFailed("Empty archive");
return; return;
} }
auto zipTask = makeShared<MMCZip::ExtractZipTask>(input, m_final_path, files[0]); auto zipTask = makeShared<MMCZip::ExtractZipTask>(zip, m_final_path, files[0]);
auto progressStep = std::make_shared<TaskStepProgress>(); auto progressStep = std::make_shared<TaskStepProgress>();
connect(zipTask.get(), &Task::finished, this, [this, progressStep] { connect(zipTask.get(), &Task::finished, this, [this, progressStep] {