ExampleCheckout: Replace the usage of Archive with Unarchiver

Change-Id: I76550b618bcc631fc9575343eb4b8552cb21a018
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-06-05 18:54:37 +02:00
parent 626378de2d
commit cd8bb1d923

View File

@@ -66,11 +66,11 @@ QString DataModelDownloader::targetPath() const
return QmlDesigner::Paths::examplesPathSetting(); return QmlDesigner::Paths::examplesPathSetting();
} }
static Utils::FilePath tempFilePath() static FilePath tempFilePath()
{ {
QStandardPaths::StandardLocation location = QStandardPaths::CacheLocation; QStandardPaths::StandardLocation location = QStandardPaths::CacheLocation;
return Utils::FilePath::fromString(QStandardPaths::writableLocation(location)) return FilePath::fromString(QStandardPaths::writableLocation(location))
.pathAppended("QtDesignStudio"); .pathAppended("QtDesignStudio");
} }
@@ -118,17 +118,18 @@ DataModelDownloader::DataModelDownloader(QObject * /* parent */)
m_started = false; m_started = false;
if (m_fileDownloader.finished()) { if (m_fileDownloader.finished()) {
const Utils::FilePath archiveFile = Utils::FilePath::fromString( const FilePath archiveFile = FilePath::fromString(m_fileDownloader.outputFile());
m_fileDownloader.outputFile()); const auto sourceAndCommand = Unarchiver::sourceAndCommand(archiveFile);
QTC_ASSERT(Utils::Archive::supportsFile(archiveFile), return ); QTC_ASSERT(sourceAndCommand, return);
auto archive = new Utils::Archive(archiveFile, tempFilePath()); auto unarchiver = new Unarchiver;
QTC_ASSERT(archive->isValid(), delete archive; return ); unarchiver->setSourceAndCommand(*sourceAndCommand);
QObject::connect(archive, &Utils::Archive::finished, this, [this, archive](bool ret) { unarchiver->setDestDir(tempFilePath());
QTC_CHECK(ret); QObject::connect(unarchiver, &Unarchiver::done, this, [this, unarchiver](bool success) {
archive->deleteLater(); QTC_CHECK(success);
unarchiver->deleteLater();
emit finished(); emit finished();
}); });
archive->unarchive(); unarchiver->start();
} }
}); });
} }
@@ -180,9 +181,9 @@ bool DataModelDownloader::available() const
return m_available; return m_available;
} }
Utils::FilePath DataModelDownloader::targetFolder() const FilePath DataModelDownloader::targetFolder() const
{ {
return Utils::FilePath::fromUserInput(tempFilePath().toString() + "/" + "dataImports"); return FilePath::fromUserInput(tempFilePath().toString() + "/" + "dataImports");
} }
void DataModelDownloader::setForceDownload(bool b) void DataModelDownloader::setForceDownload(bool b)