From 5b002940f4e891e28ae660add44c752d146778a2 Mon Sep 17 00:00:00 2001 From: Leonard Excoffier Date: Tue, 20 Feb 2024 23:02:10 -0500 Subject: [PATCH] Deleted some comments --- main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index dd800a4..f26306a 100644 --- a/main.py +++ b/main.py @@ -131,7 +131,7 @@ def save_modpack_manifest(modpack_dir, mod_filenames): def is_modpack_installed(modpack_dir): manifest_path = os.path.join(modpack_dir, 'modpack_manifest.txt') if not os.path.exists(manifest_path): - return False # Manifest does not exist, modpack likely not installed. + return False with open(manifest_path, 'r') as manifest_file: manifest_files = {line.strip() for line in manifest_file} existing_files = {file for file in os.listdir(modpack_dir) if os.path.isfile(os.path.join(modpack_dir, file))} @@ -153,14 +153,12 @@ def install_modpack(modpack_url, modpack_dir, mods_backup_dir): modpack_files = set() with zipfile.ZipFile(zip_path) as modpack_zip: for member in modpack_zip.namelist(): - if not member.endswith("/"): # Ignore directories - filename = os.path.basename(member) # Get base name to avoid directory structure - if filename: # Ignore any empty names - # Compute target path for extraction + if not member.endswith("/"): + filename = os.path.basename(member) + if filename: target_path = os.path.join(modpack_dir, filename) modpack_files.add(filename) - # Extract each file to its correct location source = modpack_zip.open(member) target = open(target_path, "wb") @@ -168,8 +166,8 @@ def install_modpack(modpack_url, modpack_dir, mods_backup_dir): shutil.copyfileobj(source, target) print("Modpack installed successfully.") - os.remove(zip_path) # Clean up the downloaded ZIP file - save_modpack_manifest(modpack_dir, modpack_files) # Update the manifest + os.remove(zip_path) + save_modpack_manifest(modpack_dir, modpack_files) except Exception as e: print(f"An error occurred during modpack installation: {e}")