diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-19 06:43:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 06:43:49 +0000 |
commit | 05315d8a236e252221bbbdd9e8f459b8a31c3524 (patch) | |
tree | 0bce187060568747888571fafedca4974fe17af3 /modules/images_history.py | |
parent | 9a33292ce41b01252cdb8ab6214a11d274e32fa0 (diff) | |
parent | 1d4aa376e6111e90888a30ae24d2bcd7f978ec51 (diff) | |
download | stable-diffusion-webui-gfx803-05315d8a236e252221bbbdd9e8f459b8a31c3524.tar.gz stable-diffusion-webui-gfx803-05315d8a236e252221bbbdd9e8f459b8a31c3524.tar.bz2 stable-diffusion-webui-gfx803-05315d8a236e252221bbbdd9e8f459b8a31c3524.zip |
Merge branch 'master' into hot-reload-javascript
Diffstat (limited to 'modules/images_history.py')
-rw-r--r-- | modules/images_history.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/images_history.py b/modules/images_history.py index 9260df8a..46b23e56 100644 --- a/modules/images_history.py +++ b/modules/images_history.py @@ -1,6 +1,6 @@ import os import shutil - +import sys def traverse_all_files(output_dir, image_list, curr_dir=None): curr_path = output_dir if curr_dir is None else os.path.join(output_dir, curr_dir) @@ -24,10 +24,14 @@ def traverse_all_files(output_dir, image_list, curr_dir=None): def get_recent_images(dir_name, page_index, step, image_index, tabname): page_index = int(page_index) - f_list = os.listdir(dir_name) image_list = [] - image_list = traverse_all_files(dir_name, image_list) - image_list = sorted(image_list, key=lambda file: -os.path.getctime(os.path.join(dir_name, file))) + if not os.path.exists(dir_name): + pass + elif os.path.isdir(dir_name): + image_list = traverse_all_files(dir_name, image_list) + image_list = sorted(image_list, key=lambda file: -os.path.getctime(os.path.join(dir_name, file))) + else: + print(f'ERROR: "{dir_name}" is not a directory. Check the path in the settings.', file=sys.stderr) num = 48 if tabname != "extras" else 12 max_page_index = len(image_list) // num + 1 page_index = max_page_index if page_index == -1 else page_index + step @@ -105,10 +109,8 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict): dir_name = opts.outdir_img2img_samples elif tabname == "extras": dir_name = opts.outdir_extras_samples - d = dir_name.split("/") - dir_name = "/" if dir_name.startswith("/") else d[0] - for p in d[1:]: - dir_name = os.path.join(dir_name, p) + else: + return with gr.Row(): renew_page = gr.Button('Renew Page', elem_id=tabname + "_images_history_renew_page") first_page = gr.Button('First Page') |