Skip to content

Commit

Permalink
added a way to update invalid items
Browse files Browse the repository at this point in the history
  • Loading branch information
faroukbmiled committed Oct 6, 2023
1 parent 46ca0f0 commit facab26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
9 changes: 7 additions & 2 deletions boiiiwd_package/src/library_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,10 @@ def check_for_updates():
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:
Expand Down Expand Up @@ -797,7 +800,9 @@ def show_full_text(event, widget, full_text):
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")

Expand Down
27 changes: 15 additions & 12 deletions boiiiwd_package/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def callback():
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:
Expand All @@ -1029,7 +1029,7 @@ def download_map(self, update=False):
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.")
Expand Down Expand Up @@ -1389,7 +1389,7 @@ def wait_for_threads():
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

Expand Down Expand Up @@ -1580,20 +1580,23 @@ def wait_for_threads():
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")
Expand Down

0 comments on commit facab26

Please sign in to comment.