Skip to content

Commit 9b0d304

Browse files
committed
remove invalid zip from interrupted previous download
1 parent e3f8b6a commit 9b0d304

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

UI_logic/MainWindow.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from shutil import rmtree, copytree
33
from sys import argv
4-
from zipfile import ZipFile
4+
from zipfile import ZipFile, BadZipFile
55

66
import requests
77
from PyQt5.QtGui import QDesktopServices, QColor, QBrush, QIcon
@@ -392,7 +392,7 @@ def start_next_download():
392392
file_url = f"{'https://stlunlocker.pro/unlocker/'}{dlc_folder}.zip"
393393
save_path = os.path.join(self.game_path, 'dlc', f'{dlc_folder}.zip')
394394
dlc_path = os.path.join(self.game_path, 'dlc', dlc_folder)
395-
395+
396396
if not os.path.exists(dlc_path) and self.is_invalid_zip(save_path):
397397
if os.path.exists(save_path):
398398
os.remove(save_path)
@@ -413,17 +413,17 @@ def update_creamapi_progress(self, value):
413413

414414
@staticmethod
415415
def is_invalid_zip(path):
416-
if not os.path.exists(path):
417-
return True
418-
if os.path.getsize(path) == 0:
419-
return True
420-
try:
421-
with zipfile.ZipFile(path, 'r') as zf:
422-
if zf.testzip() is not None:
423-
return True # Corrupted file found
424-
except zipfile.BadZipFile:
425-
return True # Not even a zip
426-
return False
416+
if not os.path.exists(path):
417+
return True
418+
if os.path.getsize(path) == 0:
419+
return True
420+
try:
421+
with ZipFile(path, 'r') as zf:
422+
if zf.testzip() is not None:
423+
return True # Corrupted file found
424+
except BadZipFile:
425+
return True # Not even a zip
426+
return False
427427

428428
def update_progress(self, value, by_download=False):
429429
self.dlc_download_progress_bar.setValue(value)

0 commit comments

Comments
 (0)