mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Avoid crash if unable to modify the model config file (#3824)
* fix whitespace; remove invisible characters * log error and proceed if unable to modify the model config
This commit is contained in:
@ -140,14 +140,14 @@ Layout of the `models` directory:
|
|||||||
|
|
||||||
models
|
models
|
||||||
├── sd-1
|
├── sd-1
|
||||||
│ ├── controlnet
|
│ ├── controlnet
|
||||||
│ ├── lora
|
│ ├── lora
|
||||||
│ ├── main
|
│ ├── main
|
||||||
│ └── embedding
|
│ └── embedding
|
||||||
├── sd-2
|
├── sd-2
|
||||||
│ ├── controlnet
|
│ ├── controlnet
|
||||||
│ ├── lora
|
│ ├── lora
|
||||||
│ ├── main
|
│ ├── main
|
||||||
│ └── embedding
|
│ └── embedding
|
||||||
└── core
|
└── core
|
||||||
├── face_reconstruction
|
├── face_reconstruction
|
||||||
@ -824,10 +824,14 @@ class ModelManager(object):
|
|||||||
assert config_file_path is not None,'no config file path to write to'
|
assert config_file_path is not None,'no config file path to write to'
|
||||||
config_file_path = self.app_config.root_path / config_file_path
|
config_file_path = self.app_config.root_path / config_file_path
|
||||||
tmpfile = os.path.join(os.path.dirname(config_file_path), "new_config.tmp")
|
tmpfile = os.path.join(os.path.dirname(config_file_path), "new_config.tmp")
|
||||||
|
try:
|
||||||
with open(tmpfile, "w", encoding="utf-8") as outfile:
|
with open(tmpfile, "w", encoding="utf-8") as outfile:
|
||||||
outfile.write(self.preamble())
|
outfile.write(self.preamble())
|
||||||
outfile.write(yaml_str)
|
outfile.write(yaml_str)
|
||||||
os.replace(tmpfile, config_file_path)
|
os.replace(tmpfile, config_file_path)
|
||||||
|
except OSError as err:
|
||||||
|
self.logger.warning(f"Could not modify the config file at {config_file_path}")
|
||||||
|
self.logger.warning(err)
|
||||||
|
|
||||||
def preamble(self) -> str:
|
def preamble(self) -> str:
|
||||||
"""
|
"""
|
||||||
@ -986,4 +990,3 @@ class ModelManager(object):
|
|||||||
successfully_installed.update(installed)
|
successfully_installed.update(installed)
|
||||||
self.commit()
|
self.commit()
|
||||||
return successfully_installed
|
return successfully_installed
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user