Deleted some comments
This commit is contained in:
14
main.py
14
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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user