mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-02-28 14:40:27 +00:00
Normalize extra_model_config.yaml paths to prevent duplicates. (#6885)
* Normalize extra_model_config.yaml paths before adding. * Fix tests. * Fix tests.
This commit is contained in:
parent
c5be423d6b
commit
29d4384a75
@ -145,7 +145,7 @@ def test_load_extra_model_paths_expands_appdata(
|
|||||||
else:
|
else:
|
||||||
expected_base_path = '/Users/TestUser/AppData/Roaming/ComfyUI'
|
expected_base_path = '/Users/TestUser/AppData/Roaming/ComfyUI'
|
||||||
expected_calls = [
|
expected_calls = [
|
||||||
('checkpoints', os.path.join(expected_base_path, 'models/checkpoints'), False),
|
('checkpoints', os.path.normpath(os.path.join(expected_base_path, 'models/checkpoints')), False),
|
||||||
]
|
]
|
||||||
|
|
||||||
assert mock_add_model_folder_path.call_count == len(expected_calls)
|
assert mock_add_model_folder_path.call_count == len(expected_calls)
|
||||||
@ -197,8 +197,8 @@ def test_load_extra_path_config_relative_base_path(
|
|||||||
|
|
||||||
load_extra_path_config(dummy_yaml_name)
|
load_extra_path_config(dummy_yaml_name)
|
||||||
|
|
||||||
expected_checkpoints = os.path.abspath(os.path.join(str(tmp_path), sub_folder, "checkpoints"))
|
expected_checkpoints = os.path.abspath(os.path.join(str(tmp_path), "my_rel_base", "checkpoints"))
|
||||||
expected_some_value = os.path.abspath(os.path.join(str(tmp_path), sub_folder, "some_value"))
|
expected_some_value = os.path.abspath(os.path.join(str(tmp_path), "my_rel_base", "some_value"))
|
||||||
|
|
||||||
actual_paths = folder_paths.folder_names_and_paths["checkpoints"][0]
|
actual_paths = folder_paths.folder_names_and_paths["checkpoints"][0]
|
||||||
assert len(actual_paths) == 1, "Should have one path added for 'checkpoints'."
|
assert len(actual_paths) == 1, "Should have one path added for 'checkpoints'."
|
||||||
|
@ -29,5 +29,6 @@ def load_extra_path_config(yaml_path):
|
|||||||
full_path = os.path.join(base_path, full_path)
|
full_path = os.path.join(base_path, full_path)
|
||||||
elif not os.path.isabs(full_path):
|
elif not os.path.isabs(full_path):
|
||||||
full_path = os.path.abspath(os.path.join(yaml_dir, y))
|
full_path = os.path.abspath(os.path.join(yaml_dir, y))
|
||||||
logging.info("Adding extra search path {} {}".format(x, full_path))
|
normalized_path = os.path.normpath(full_path)
|
||||||
folder_paths.add_model_folder_path(x, full_path, is_default)
|
logging.info("Adding extra search path {} {}".format(x, normalized_path))
|
||||||
|
folder_paths.add_model_folder_path(x, normalized_path, is_default)
|
||||||
|
Loading…
Reference in New Issue
Block a user