Workaround windows *sigh* because it wants to be different.

pull/520/head
Adam Treat 1 year ago
parent 7ce6b6ba89
commit 8208ece6d3

@ -46,22 +46,45 @@ QList<ModelInfo> Download::modelList() const
QString Download::downloadLocalModelsPath() const QString Download::downloadLocalModelsPath() const
{ {
QString exePath = QCoreApplication::applicationDirPath() + QDir::separator(); {
QFileInfo infoExe(exePath); QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
if (infoExe.isWritable()) QString testWritePath = exePath + QString("test_write.txt");
return exePath; QString canonicalExePath = QFileInfo(exePath).canonicalFilePath() + QDir::separator();
if (QFileInfo::exists(testWritePath))
QString localPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); return canonicalExePath;
QDir localDir(localPath);
if (!localDir.exists()) QFile testWriteFile(testWritePath);
localDir.mkpath(localPath); if (testWriteFile.open(QIODeviceBase::ReadWrite)) {
QString localDownloadPath = localPath testWriteFile.close();
+ QDir::separator(); return canonicalExePath;
QFileInfo infoLocal(localDownloadPath); }
if (infoLocal.isWritable()) }
return localDownloadPath;
qWarning() << "ERROR: Local download path appears not writeable:" << localDownloadPath; {
return localDownloadPath; QString localPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
+ QDir::separator();
QString testWritePath = localPath + QString("test_write.txt");
QString canonicalLocalPath = QFileInfo(localPath).canonicalFilePath() + QDir::separator();
QDir localDir(localPath);
if (!localDir.exists()) {
if (!localDir.mkpath(localPath)) {
qWarning() << "ERROR: Local download directory can't be created:" << canonicalLocalPath;
return canonicalLocalPath;
}
}
if (QFileInfo::exists(testWritePath))
return canonicalLocalPath;
QFile testWriteFile(testWritePath);
if (testWriteFile.open(QIODeviceBase::ReadWrite)) {
testWriteFile.close();
return canonicalLocalPath;
}
qWarning() << "ERROR: Local download path appears not writeable:" << canonicalLocalPath;
return canonicalLocalPath;
}
} }
void Download::updateModelList() void Download::updateModelList()

Loading…
Cancel
Save