Skip to content

Commit

Permalink
Fix pack exist check with empty source
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu authored and gmjosack committed Dec 18, 2023
1 parent 4f2077b commit 9b50901
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/modlunky2/ui/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def __init__(self, parent, modlunky_config: Config):
file_chooser_browse.grid(row=3, column=0, pady=5, padx=5, sticky="nsew")

def changed(self, val):
self.master.master.check_exists(val)
self.master.master.check_exists(
self.master.master.file_chooser_frame.file_chooser_var.get(), val
)
return True

def browse(self):
Expand Down Expand Up @@ -253,9 +255,15 @@ def install(self):
pack=pack,
)

def check_exists(self, dest):
def check_exists(self, source, dest):
source_path = Path(source)
dest_path = self.modlunky_config.install_dir / "Mods/Packs" / Path(dest).stem
if not dest:
if (
not dest
or not source
or not source_path.exists()
or not source_path.is_file()
):
self.button_install["state"] = tk.DISABLED
return
self.button_install["state"] = tk.NORMAL
Expand All @@ -272,7 +280,7 @@ def render(self):
dest = self.file_chooser_frame2.file_chooser_var.get()
if source and dest:
self.button_install["state"] = tk.NORMAL
self.check_exists(dest)
self.check_exists(source, dest)
else:
self.button_install["state"] = tk.DISABLED
self.button_install[
Expand Down

0 comments on commit 9b50901

Please sign in to comment.