From facab26ff2b6ab5105c5bba82beaa49b71dd8b44 Mon Sep 17 00:00:00 2001 From: faroukbmiled Date: Fri, 6 Oct 2023 13:56:46 +0100 Subject: [PATCH 1/2] added a way to update invalid items --- boiiiwd_package/src/library_tab.py | 9 +++++++-- boiiiwd_package/src/main.py | 27 +++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/boiiiwd_package/src/library_tab.py b/boiiiwd_package/src/library_tab.py index 9281fc0..95027a3 100644 --- a/boiiiwd_package/src/library_tab.py +++ b/boiiiwd_package/src/library_tab.py @@ -683,7 +683,10 @@ class LibraryTab(ctk.CTkScrollableFrame): main_app.app.edit_workshop_id.delete(0, "end") main_app.app.edit_workshop_id.insert(0, workshop_id) main_app.app.main_button_event() - main_app.app.download_map(update=True) + if invalid_warn and check_config("update_invalid", "no") == "yes": + main_app.app.download_map(update=True, invalid_item_folder=os.path.basename(folder)) + else: + main_app.app.download_map(update=True) top.destroy() return else: @@ -797,7 +800,9 @@ class LibraryTab(ctk.CTkScrollableFrame): update_btn.configure(state="disabled") update_btn_tooltip.configure(message="Currently offline") view_button_tooltip.configure(message="Currently offline") - if invalid_warn: + if check_config("update_invalid", "no") == "yes": + update_btn_tooltip.configure(message="update_invalid is set to 'yes' in config.ini") + elif invalid_warn: update_btn.configure(text="Update", state="disabled") update_btn_tooltip.configure(message="Disabled due to item being blocked or duplicated") diff --git a/boiiiwd_package/src/main.py b/boiiiwd_package/src/main.py index e0a416c..931e140 100644 --- a/boiiiwd_package/src/main.py +++ b/boiiiwd_package/src/main.py @@ -1017,7 +1017,7 @@ class BOIIIWD(ctk.CTk): self.after(0, callback) @if_internet_available - def download_map(self, update=False): + def download_map(self, update=False, invalid_item_folder=None): self.is_downloading = False self.fail_threshold = 0 if not self.is_pressed: @@ -1029,7 +1029,7 @@ class BOIIIWD(ctk.CTk): start_down_thread = threading.Thread(target=self.queue_download_thread, args=(update,)) start_down_thread.start() else: - start_down_thread = threading.Thread(target=self.download_thread, args=(update,)) + start_down_thread = threading.Thread(target=self.download_thread, args=(update, invalid_item_folder,)) start_down_thread.start() else: show_message("Warning", "Already pressed, Please wait.") @@ -1389,7 +1389,7 @@ class BOIIIWD(ctk.CTk): self.stop_download() self.is_pressed = False - def download_thread(self, update=None): + def download_thread(self, update=None, invalid_item_folder=None): try: self.settings_tab.stopped = False @@ -1580,20 +1580,23 @@ class BOIIIWD(ctk.CTk): items_file = os.path.join(APPLICATION_PATH, LIBRARY_FILE) item_exists,_ = self.library_tab.item_exists_in_file(items_file, workshop_id) - if item_exists: - get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") - if get_folder_name: - folder_name = get_folder_name + if invalid_item_folder: + folder_name = invalid_item_folder + else: + if item_exists: + get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") + if get_folder_name: + folder_name = get_folder_name + else: + try: + folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) + except: + folder_name = extract_json_data(json_file_path, "publisherID") else: try: folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) except: folder_name = extract_json_data(json_file_path, "publisherID") - else: - try: - folder_name = extract_json_data(json_file_path, self.settings_tab.folder_options.get()) - except: - folder_name = extract_json_data(json_file_path, "publisherID") if mod_type == "mod": path_folder = os.path.join(destination_folder, "mods") From 5355675a6ac89fecfdcab8590be3ed04e6717dea Mon Sep 17 00:00:00 2001 From: faroukbmiled Date: Fri, 6 Oct 2023 14:11:38 +0100 Subject: [PATCH 2/2] invalid items now have proper down dates --- boiiiwd_package/src/library_tab.py | 10 ++++++++++ boiiiwd_package/src/main.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/boiiiwd_package/src/library_tab.py b/boiiiwd_package/src/library_tab.py index 95027a3..0d91893 100644 --- a/boiiiwd_package/src/library_tab.py +++ b/boiiiwd_package/src/library_tab.py @@ -635,6 +635,16 @@ class LibraryTab(ctk.CTkScrollableFrame): if offline_date: down_date = offline_date + elif invalid_warn: + try: + zone_path = Path(folder) / "zone" + for ff_file in zone_path.glob("*.ff"): + if ff_file.exists(): + creation_timestamp = ff_file.stat().st_mtime + break + down_date = datetime.fromtimestamp(creation_timestamp).strftime("%d %b, %Y @ %I:%M%p") + except: + down_date = "Failed to get download date" else: down_date = self.get_item_by_id(items_file, workshop_id, 'date') diff --git a/boiiiwd_package/src/main.py b/boiiiwd_package/src/main.py index 931e140..9b3cc11 100644 --- a/boiiiwd_package/src/main.py +++ b/boiiiwd_package/src/main.py @@ -1625,7 +1625,8 @@ class BOIIIWD(ctk.CTk): remove_tree(map_folder) remove_tree(download_folder) - self.library_tab.update_item(self.edit_destination_folder.get(), workshop_id, mod_type, folder_name) + if not invalid_item_folder: + self.library_tab.update_item(self.edit_destination_folder.get(), workshop_id, mod_type, folder_name) self.show_complete_message(message=f"{mod_type.capitalize()} files were downloaded\nYou can run the game now!\nPS: You have to restart the game \n(pressing launch will launch/restarts)") self.button_download.configure(state="normal") self.button_stop.configure(state="disabled")