Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -5488,20 +5488,25 @@ void Application::addAssetToWorldFromURLRequestFinished() { · 5487 unmodified lines | ||
| 5488 | 5488 | |
| 5489 | 5489 | if (result == ResourceRequest::Success) { |
| 5490 | 5490 | qInfo(interfaceapp) << "Downloaded asset from" << url; |
| 5491 | − | |
| 5492 | 5491 | QTemporaryDir temporaryDir; |
| 5493 | 5492 | temporaryDir.setAutoRemove(false); |
| 5494 | − QString temporaryDirPath = temporaryDir.path(); | |
| 5495 | − QString filename = url.section("filename=", 1, 1); | |
| 5496 | − QString downloadPath = temporaryDirPath + "/" + filename; | |
| 5497 | − qInfo() << "Download path:" << downloadPath; | |
| 5498 | − | |
| 5499 | − QFile tempFile(downloadPath); | |
| 5500 | − if (tempFile.open(QIODevice::WriteOnly)) { | |
| 5501 | − tempFile.write(request->getData()); | |
| 5502 | − qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true); | |
| 5493 | + if (temporaryDir.isValid()) { | |
| 5494 | + QString temporaryDirPath = temporaryDir.path(); | |
| 5495 | + QString filename = url.section("filename=", 1, 1); | |
| 5496 | + QString downloadPath = temporaryDirPath + "/" + filename; | |
| 5497 | + qInfo() << "Download path:" << downloadPath; | |
| 5498 | + | |
| 5499 | + QFile tempFile(downloadPath); | |
| 5500 | + if (tempFile.open(QIODevice::WriteOnly)) { | |
| 5501 | + tempFile.write(request->getData()); | |
| 5502 | + qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true); | |
| 5503 | + } else { | |
| 5504 | + QString errorInfo = "Couldn't open temporary file for download"; | |
| 5505 | + qWarning(interfaceapp) << errorInfo; | |
| 5506 | + addAssetToWorldError(errorInfo); | |
| 5507 | + } | |
| 5503 | 5508 | } else { |
| 5504 | − QString errorInfo = "Couldn't open temporary file for writing"; | |
| 5509 | + QString errorInfo = "Couldn't create temporary directory for download"; | |
| 5505 | 5510 | qWarning(interfaceapp) << errorInfo; |
| 5506 | 5511 | addAssetToWorldError(errorInfo); |
| 5507 | 5512 | } |