allow deletion of symlinked models in models dir

This commit is contained in:
Lincoln Stein 2024-03-22 19:41:34 -04:00 committed by Kent Keirsey
parent 37fd57d4d9
commit 0f02a72cb9

View File

@ -390,10 +390,10 @@ class ModelInstallService(ModelInstallServiceBase):
def unconditionally_delete(self, key: str) -> None: # noqa D102 def unconditionally_delete(self, key: str) -> None: # noqa D102
model = self.record_store.get_model(key) model = self.record_store.get_model(key)
model_path = self.app_config.models_path / model.path model_path = self.app_config.models_path / model.path
if model_path.is_dir(): if model_path.is_file() or model_path.is_symlink():
rmtree(model_path)
else:
model_path.unlink() model_path.unlink()
elif model_path.is_dir():
rmtree(model_path)
self.unregister(key) self.unregister(key)
def download_and_cache( def download_and_cache(