Skip to content

Commit

Permalink
Add support for extracting files in .7z format from folder
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 authored Jun 12, 2022
1 parent 42411e1 commit 10a4975
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bot/modules/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def onDownloadComplete(self):
if os.path.isdir(m_path):
for dirpath, subdir, files in os.walk(m_path, topdown=False):
for file_ in files:
if file_.endswith(".zip") or re.search(r'\.part0*1\.rar$|\.7z\.0*1$|\.zip\.0*1$', file_) \
if file_.endswith((".zip", ".7z")) or re.search(r'\.part0*1\.rar$|\.7z\.0*1$|\.zip\.0*1$', file_) \
or (file_.endswith(".rar") and not re.search(r'\.part\d+\.rar$', file_)):
m_path = os.path.join(dirpath, file_)
if self.pswd is not None:
Expand All @@ -85,7 +85,7 @@ def onDownloadComplete(self):
if result.returncode != 0:
LOGGER.error("Failed to extract the archive")
for file_ in files:
if file_.endswith((".rar", ".zip")) or re.search(r'\.r\d+$|\.7z\.\d+$|\.z\d+$|\.zip\.\d+$', file_):
if file_.endswith((".rar", ".zip", ".7z")) or re.search(r'\.r\d+$|\.7z\.\d+$|\.z\d+$|\.zip\.\d+$', file_):
del_path = os.path.join(dirpath, file_)
os.remove(del_path)
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
Expand All @@ -99,8 +99,8 @@ def onDownloadComplete(self):
else:
LOGGER.error("Failed to extract the archive")
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
except CompressExceptionHandler:
LOGGER.info("Not a valid archive")
except CompressExceptionHandler as err:
LOGGER.info(err)
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
else:
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
Expand Down

0 comments on commit 10a4975

Please sign in to comment.