mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Workaround windows *sigh* because it wants to be different.
This commit is contained in:
parent
7ce6b6ba89
commit
8208ece6d3
49
download.cpp
49
download.cpp
@ -45,23 +45,46 @@ QList<ModelInfo> Download::modelList() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Download::downloadLocalModelsPath() const
|
QString Download::downloadLocalModelsPath() const
|
||||||
|
{
|
||||||
{
|
{
|
||||||
QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
QFileInfo infoExe(exePath);
|
QString testWritePath = exePath + QString("test_write.txt");
|
||||||
if (infoExe.isWritable())
|
QString canonicalExePath = QFileInfo(exePath).canonicalFilePath() + QDir::separator();
|
||||||
return exePath;
|
if (QFileInfo::exists(testWritePath))
|
||||||
|
return canonicalExePath;
|
||||||
|
|
||||||
QString localPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
QFile testWriteFile(testWritePath);
|
||||||
QDir localDir(localPath);
|
if (testWriteFile.open(QIODeviceBase::ReadWrite)) {
|
||||||
if (!localDir.exists())
|
testWriteFile.close();
|
||||||
localDir.mkpath(localPath);
|
return canonicalExePath;
|
||||||
QString localDownloadPath = localPath
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QString localPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
|
||||||
+ QDir::separator();
|
+ QDir::separator();
|
||||||
QFileInfo infoLocal(localDownloadPath);
|
QString testWritePath = localPath + QString("test_write.txt");
|
||||||
if (infoLocal.isWritable())
|
QString canonicalLocalPath = QFileInfo(localPath).canonicalFilePath() + QDir::separator();
|
||||||
return localDownloadPath;
|
QDir localDir(localPath);
|
||||||
qWarning() << "ERROR: Local download path appears not writeable:" << localDownloadPath;
|
if (!localDir.exists()) {
|
||||||
return localDownloadPath;
|
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…
Reference in New Issue
Block a user