Skip to content

Commit 5c1e185

Browse files
committed
Support split archives
1 parent 08899ae commit 5c1e185

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

common.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,15 +878,25 @@ def __init__(self, errorReason):
878878
def __str__(self):
879879
return self.errorReason
880880

881+
# Split archives are usually something like 'test.7z.001', 'test.7z.002' or 'test.zip.013'
882+
split_file_regex = re.compile(r'\.(\d+)$')
883+
881884
def extractOrCopyFile(filename, sourceFolder, destinationFolder, copiedOutputFileName=None):
882885
makeDirsExistOK(destinationFolder)
883886
sourcePath = os.path.join(sourceFolder, filename)
884887

885888
if '.7z' in filename.lower() or '.zip' in filename.lower():
889+
split_extension = split_file_regex.search(filename.lower())
890+
if split_extension:
891+
split_archive_number = int(split_extension.group(1))
892+
# Assume archive numbers start at 1
893+
# Only process split archives where the index is '1', ignore all others as they will be processed automatically
894+
if split_archive_number != 1:
895+
return
896+
886897
monitor = SevenZipMonitor()
887898
if sevenZipExtract(sourcePath, outputDir=destinationFolder, lineMonitor=monitor) != 0:
888899
raise SevenZipException("{}\n\n Could not extract [{}]".format(monitor.getErrorMessage(), sourcePath))
889-
890900
else:
891901
try:
892902
shutil.copy(sourcePath, os.path.join(destinationFolder, copiedOutputFileName if copiedOutputFileName else filename))

0 commit comments

Comments
 (0)