Skip to content

Commit

Permalink
fix(mm): only move model files if necessary
Browse files Browse the repository at this point in the history
The old logic to check if a model needed to be moved relied on the model path being a relative path. Paths are now absolute, causing this check to fail. We then assumed the paths were different and moved the model from its current location to, well, its current location.

Use more resilient method to check if a model should be moved.
  • Loading branch information
psychedelicious committed Mar 9, 2024
1 parent f01e81d commit 67163c2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion invokeai/app/services/model_install/model_install_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,17 @@ def _sync_model_path(self, key: str) -> AnyModelConfig:
old_path = Path(model.path)
models_dir = self.app_config.models_path

if not old_path.is_relative_to(models_dir):
try:
old_path.relative_to(models_dir)
return model
except ValueError:
pass

new_path = models_dir / model.base.value / model.type.value / model.name

if old_path == new_path:
return model

self._logger.info(f"Moving {model.name} to {new_path}.")
new_path = self._move_model(old_path, new_path)
model.path = new_path.as_posix()
Expand Down

0 comments on commit 67163c2

Please sign in to comment.