mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-20 18:19:49 +00:00
modellist: refactor some lambdas into functions
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
d098426e0c
commit
f6c8c7cb90
@ -1210,12 +1210,8 @@ bool ModelList::modelExists(const QString &modelFilename) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelList::updateModelsFromDirectory()
|
static void updateOldRemoteModels(const QString &path)
|
||||||
{
|
{
|
||||||
const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
|
||||||
const QString localPath = MySettings::globalInstance()->modelPath();
|
|
||||||
|
|
||||||
auto updateOldRemoteModels = [&](const QString& path) {
|
|
||||||
QDirIterator it(path, QDirIterator::Subdirectories);
|
QDirIterator it(path, QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
@ -1249,9 +1245,10 @@ void ModelList::updateModelsFromDirectory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
auto processDirectory = [&](const QString& path) {
|
void ModelList::processModelDirectory(const QString &path)
|
||||||
|
{
|
||||||
QDirIterator it(path, QDir::Files, QDirIterator::Subdirectories);
|
QDirIterator it(path, QDir::Files, QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
@ -1328,14 +1325,18 @@ void ModelList::updateModelsFromDirectory()
|
|||||||
updateData(id, data);
|
updateData(id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void ModelList::updateModelsFromDirectory()
|
||||||
|
{
|
||||||
|
const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
|
const QString localPath = MySettings::globalInstance()->modelPath();
|
||||||
|
|
||||||
updateOldRemoteModels(exePath);
|
updateOldRemoteModels(exePath);
|
||||||
processDirectory(exePath);
|
processModelDirectory(exePath);
|
||||||
if (localPath != exePath) {
|
if (localPath != exePath) {
|
||||||
updateOldRemoteModels(localPath);
|
updateOldRemoteModels(localPath);
|
||||||
processDirectory(localPath);
|
processModelDirectory(localPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,6 +509,7 @@ private:
|
|||||||
void parseModelsJsonFile(const QByteArray &jsonData, bool save);
|
void parseModelsJsonFile(const QByteArray &jsonData, bool save);
|
||||||
void parseDiscoveryJsonFile(const QByteArray &jsonData);
|
void parseDiscoveryJsonFile(const QByteArray &jsonData);
|
||||||
QString uniqueModelName(const ModelInfo &model) const;
|
QString uniqueModelName(const ModelInfo &model) const;
|
||||||
|
void processModelDirectory(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QMutex m_mutex;
|
mutable QMutex m_mutex;
|
||||||
|
Loading…
Reference in New Issue
Block a user