mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 09:31:57 +02:00
Improve temporary download directory robustness
This commit is contained in:
parent
eafd51ba9e
commit
186d3f18ef
1 changed files with 15 additions and 10 deletions
|
@ -5488,20 +5488,25 @@ void Application::addAssetToWorldFromURLRequestFinished() {
|
|||
|
||||
if (result == ResourceRequest::Success) {
|
||||
qInfo(interfaceapp) << "Downloaded asset from" << url;
|
||||
|
||||
QTemporaryDir temporaryDir;
|
||||
temporaryDir.setAutoRemove(false);
|
||||
QString temporaryDirPath = temporaryDir.path();
|
||||
QString filename = url.section("filename=", 1, 1);
|
||||
QString downloadPath = temporaryDirPath + "/" + filename;
|
||||
qInfo() << "Download path:" << downloadPath;
|
||||
if (temporaryDir.isValid()) {
|
||||
QString temporaryDirPath = temporaryDir.path();
|
||||
QString filename = url.section("filename=", 1, 1);
|
||||
QString downloadPath = temporaryDirPath + "/" + filename;
|
||||
qInfo() << "Download path:" << downloadPath;
|
||||
|
||||
QFile tempFile(downloadPath);
|
||||
if (tempFile.open(QIODevice::WriteOnly)) {
|
||||
tempFile.write(request->getData());
|
||||
qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true);
|
||||
QFile tempFile(downloadPath);
|
||||
if (tempFile.open(QIODevice::WriteOnly)) {
|
||||
tempFile.write(request->getData());
|
||||
qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true);
|
||||
} else {
|
||||
QString errorInfo = "Couldn't open temporary file for download";
|
||||
qWarning(interfaceapp) << errorInfo;
|
||||
addAssetToWorldError(errorInfo);
|
||||
}
|
||||
} else {
|
||||
QString errorInfo = "Couldn't open temporary file for writing";
|
||||
QString errorInfo = "Couldn't create temporary directory for download";
|
||||
qWarning(interfaceapp) << errorInfo;
|
||||
addAssetToWorldError(errorInfo);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue