From 6524478850ba1b285fee2593b113dfb726b0bd9f Mon Sep 17 00:00:00 2001 From: spezialspezial <75758219+spezialspezial@users.noreply.github.com> Date: Sat, 4 Feb 2023 16:52:15 +0100 Subject: [PATCH 1/5] Update modelloader.py os.path.getmtime(filename) throws exception later in codepath when meeting broken symlink. For now catch it here early but more checks could be added for robustness. --- modules/modelloader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/modelloader.py b/modules/modelloader.py index e9aa514eb..fc3f6249f 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -45,6 +45,9 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None full_path = file if os.path.isdir(full_path): continue + if os.path.islink(full_path) and not os.path.exists(full_path): + print(f"Skipping broken symlink: {full_path}") + continue if ext_blacklist is not None and any([full_path.endswith(x) for x in ext_blacklist]): continue if len(ext_filter) != 0: From 88a46e8427fbaa73eb37c9eaabbb62b8647a5f32 Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Sat, 4 Feb 2023 09:10:00 -0800 Subject: [PATCH 2/5] fix symlinks in extra networks ui 'absolute' and 'resolve' are equivalent, but 'resolve' resolves symlinks (which is an obscure specialty behavior usually not wanted) whereas 'absolute' treats symlinks as folders (which is the expected behavior). This commit allows you to symlink folders within your models/embeddings/etc. dirs and have preview images load as expected without issue. --- modules/ui_extra_networks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 95b30f4ab..90abec0a5 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -26,7 +26,7 @@ def add_pages_to_demo(app): def fetch_file(filename: str = ""): from starlette.responses import FileResponse - if not any([Path(x).resolve() in Path(filename).resolve().parents for x in allowed_dirs]): + if not any([Path(x).absolute() in Path(filename).absolute().parents for x in allowed_dirs]): raise ValueError(f"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages.") ext = os.path.splitext(filename)[1].lower() From 5a1b62e9f8048e20a9ff47df73b16f8a0b5e673c Mon Sep 17 00:00:00 2001 From: techneconn Date: Sun, 5 Feb 2023 15:48:51 +0900 Subject: [PATCH 3/5] Add prompt_hash option for file/dir name pattern --- javascript/hints.js | 4 ++-- modules/images.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/hints.js b/javascript/hints.js index 75792d0dd..9aa82f246 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -66,8 +66,8 @@ titles = { "Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.", - "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_no_styles], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [model_name], [prompt_words], [date], [datetime], [datetime], [datetime