mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-05 11:36:16 +00:00
fix removal of models in subdirectories
removeModel is starting to make sense now. Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
f8143361d3
commit
8a64b039dc
@ -441,9 +441,7 @@ Rectangle {
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||
visible: !isDownloading && (installed || isIncomplete)
|
||||
Accessible.description: qsTr("Remove model from filesystem")
|
||||
onClicked: {
|
||||
Download.removeModel(filename);
|
||||
}
|
||||
onClicked: Download.removeModel(id)
|
||||
}
|
||||
|
||||
MySettingsButton {
|
||||
|
@ -221,9 +221,7 @@ Rectangle {
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||
visible: !isDownloading && (installed || isIncomplete)
|
||||
Accessible.description: qsTr("Remove model from filesystem")
|
||||
onClicked: {
|
||||
Download.removeModel(filename);
|
||||
}
|
||||
onClicked: Download.removeModel(id)
|
||||
}
|
||||
|
||||
MySettingsButton {
|
||||
|
@ -328,27 +328,28 @@ void Download::installCompatibleModel(const QString &modelName, const QString &a
|
||||
ModelList::globalInstance()->updateDataByFilename(modelFile, {{ ModelList::InstalledRole, true }});
|
||||
}
|
||||
|
||||
void Download::removeModel(const QString &modelFile)
|
||||
// FIXME(jared): With the current implementation, it is not possible to remove a duplicate
|
||||
// model file (same filename, different subdirectory) from within GPT4All
|
||||
// without restarting it.
|
||||
void Download::removeModel(const QString &id)
|
||||
{
|
||||
auto *modelList = ModelList::globalInstance();
|
||||
auto *mySettings = MySettings::globalInstance();
|
||||
|
||||
QFile incompleteFile(modelList->incompleteDownloadPath(modelFile));
|
||||
if (incompleteFile.exists())
|
||||
incompleteFile.remove();
|
||||
auto info = modelList->modelInfo(id);
|
||||
if (info.id().isEmpty())
|
||||
return;
|
||||
|
||||
bool shouldRemoveInstalled = false;
|
||||
Network::globalInstance()->trackEvent("remove_model", { {"model", info.filename()} });
|
||||
|
||||
QFile file(mySettings->modelPath() + modelFile);
|
||||
const ModelInfo info = modelList->modelInfoByFilename(modelFile);
|
||||
// remove incomplete download
|
||||
QFile(modelList->incompleteDownloadPath(info.filename())).remove();
|
||||
|
||||
Network::globalInstance()->trackEvent("remove_model", { {"model", modelFile}, {"exists", file.exists()} });
|
||||
// remove file, if this is a real model
|
||||
if (!info.isClone())
|
||||
QFile(info.path()).remove();
|
||||
|
||||
if (file.exists()) {
|
||||
modelList->uninstall(info);
|
||||
if (!info.isClone())
|
||||
file.remove();
|
||||
}
|
||||
// remove model list entry
|
||||
modelList->uninstall(info);
|
||||
|
||||
emit toastMessage(tr("Model \"%1\" is removed.").arg(info.name()));
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
Q_INVOKABLE void cancelDownload(const QString &modelFile);
|
||||
Q_INVOKABLE void installModel(const QString &modelFile, const QString &apiKey);
|
||||
Q_INVOKABLE void installCompatibleModel(const QString &modelName, const QString &apiKey, const QString &baseUrl);
|
||||
Q_INVOKABLE void removeModel(const QString &modelFile);
|
||||
Q_INVOKABLE void removeModel(const QString &id);
|
||||
Q_INVOKABLE bool isFirstStart(bool writeVersion = false) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
Loading…
Reference in New Issue
Block a user