diff --git a/README.md b/README.md index 0103298..5742ab6 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,9 @@ From v1.5, v1.x goes into maintenance phase. Enjoy! # Change Log +## v1.5.3 +* When downloading a model by url, check if target model version is already existed in user selected sub-folder. + ## v1.5.2 * Support scanning only selected model types. diff --git a/scripts/civitai_helper.py b/scripts/civitai_helper.py index 3ba6a76..670fbcf 100644 --- a/scripts/civitai_helper.py +++ b/scripts/civitai_helper.py @@ -164,7 +164,7 @@ def on_ui_tabs(): # Get Civitai Model Info by Model Page URL model_type_drop.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop) empty_info_only_ckb.change(get_model_names_by_input, inputs=[model_type_drop, empty_info_only_ckb], outputs=model_name_drop) - + get_civitai_model_info_by_id_btn.click(model_action_civitai.get_model_info_by_input, inputs=[model_type_drop, model_name_drop, model_url_or_id_txtbox, max_size_preview_ckb, skip_nsfw_preview_ckb], outputs=get_model_by_id_log_md) # Download Model diff --git a/scripts/lib/js_action_civitai.py b/scripts/lib/js_action_civitai.py index 00a9430..0c81853 100644 --- a/scripts/lib/js_action_civitai.py +++ b/scripts/lib/js_action_civitai.py @@ -221,6 +221,14 @@ def dl_model_new_version(msg, max_size_preview, skip_nsfw_preview): # get model folder from model path model_folder = os.path.dirname(model_path) + # no need to check when downloading new version, since checking new version is already checked + # check if this model is already existed + # r = civitai.search_local_model_info_by_version_id(model_folder, version_id) + # if r: + # output = "This model version is already existed" + # util.printD(output) + # return output + # download file new_model_path = downloader.dl(download_url, model_folder, None, None) if not new_model_path: diff --git a/scripts/lib/model_action_civitai.py b/scripts/lib/model_action_civitai.py index e240708..6238fe1 100644 --- a/scripts/lib/model_action_civitai.py +++ b/scripts/lib/model_action_civitai.py @@ -401,6 +401,13 @@ def dl_model_by_input(model_info:dict, model_type:str, subfolder_str:str, versio util.printD(output) return output + # check if this model is already existed + r = civitai.search_local_model_info_by_version_id(model_folder, version_id) + if r: + output = "This model version is already existed" + util.printD(output) + return output + # download filepath = downloader.dl(url, model_folder, None, None) if not filepath: diff --git a/scripts/lib/util.py b/scripts/lib/util.py index 1d90155..7c0fbce 100644 --- a/scripts/lib/util.py +++ b/scripts/lib/util.py @@ -4,7 +4,7 @@ import hashlib import requests import shutil -version = "1.5.2" +version = "1.5.3" # print for debugging def printD(msg):