mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Merge pull request #608 from willmiao/codex/fix-example-images-download-path-issue
fix: allow legacy library folders when validating example image paths
This commit is contained in:
@@ -199,10 +199,13 @@ def is_valid_example_images_root(folder_path: str) -> bool:
|
|||||||
if item == "_deleted":
|
if item == "_deleted":
|
||||||
# Allow cleanup staging folders
|
# Allow cleanup staging folders
|
||||||
continue
|
continue
|
||||||
# When multi-library mode is active we expect nested hash folders
|
# Accept legacy library folders even when current settings do not
|
||||||
if uses_library_scoped_folders():
|
# explicitly enable multi-library mode. This allows users to reuse a
|
||||||
if _library_folder_has_only_hash_dirs(item_path):
|
# previously configured example images directory after settings are
|
||||||
continue
|
# reset, as long as the nested structure still looks like dedicated
|
||||||
|
# hash folders.
|
||||||
|
if _library_folder_has_only_hash_dirs(item_path):
|
||||||
|
continue
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -125,3 +125,18 @@ def test_is_valid_example_images_root_accepts_hash_directories(tmp_path, setting
|
|||||||
# Add a non-hash file to make it clearly invalid
|
# Add a non-hash file to make it clearly invalid
|
||||||
(invalid_folder / 'invalid.txt').write_text('invalid', encoding='utf-8')
|
(invalid_folder / 'invalid.txt').write_text('invalid', encoding='utf-8')
|
||||||
assert is_valid_example_images_root(str(tmp_path)) is False
|
assert is_valid_example_images_root(str(tmp_path)) is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_valid_example_images_root_accepts_legacy_library_structure(tmp_path, settings_manager):
|
||||||
|
settings_manager.settings['example_images_path'] = str(tmp_path)
|
||||||
|
# Simulate settings reset where libraries configuration is missing
|
||||||
|
settings_manager.settings['libraries'] = {'default': {}}
|
||||||
|
settings_manager.settings['active_library'] = 'default'
|
||||||
|
|
||||||
|
legacy_library = tmp_path / 'My Library'
|
||||||
|
legacy_library.mkdir()
|
||||||
|
hash_folder = legacy_library / ('e' * 64)
|
||||||
|
hash_folder.mkdir()
|
||||||
|
(hash_folder / 'image.png').write_text('data', encoding='utf-8')
|
||||||
|
|
||||||
|
assert is_valid_example_images_root(str(tmp_path)) is True
|
||||||
|
|||||||
Reference in New Issue
Block a user