mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 17:56:30 +00:00
Optimize archive extraction for zip/rar files (closes #40)
This commit is contained in:
@@ -38,6 +38,7 @@ class CBxArchive:
|
|||||||
|
|
||||||
def extractCBZ(self, targetdir):
|
def extractCBZ(self, targetdir):
|
||||||
cbzFile = zipfile.ZipFile(self.origFileName)
|
cbzFile = zipfile.ZipFile(self.origFileName)
|
||||||
|
filelist = []
|
||||||
for f in cbzFile.namelist():
|
for f in cbzFile.namelist():
|
||||||
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
|
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
|
||||||
pass # skip MacOS special files
|
pass # skip MacOS special files
|
||||||
@@ -47,10 +48,12 @@ class CBxArchive:
|
|||||||
except:
|
except:
|
||||||
pass # the dir exists so we are going to extract the images only.
|
pass # the dir exists so we are going to extract the images only.
|
||||||
else:
|
else:
|
||||||
cbzFile.extract(f, targetdir)
|
filelist.append(f)
|
||||||
|
cbzFile.extractall(targetdir, filelist)
|
||||||
|
|
||||||
def extractCBR(self, targetdir):
|
def extractCBR(self, targetdir):
|
||||||
cbrFile = rarfile.RarFile(self.origFileName)
|
cbrFile = rarfile.RarFile(self.origFileName)
|
||||||
|
filelist = []
|
||||||
for f in cbrFile.namelist():
|
for f in cbrFile.namelist():
|
||||||
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
|
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
|
||||||
pass # skip MacOS special files
|
pass # skip MacOS special files
|
||||||
@@ -60,9 +63,11 @@ class CBxArchive:
|
|||||||
except:
|
except:
|
||||||
pass # the dir exists so we are going to extract the images only.
|
pass # the dir exists so we are going to extract the images only.
|
||||||
else:
|
else:
|
||||||
cbrFile.extract(f, targetdir)
|
filelist.append(f)
|
||||||
|
cbrFile.extractall(targetdir, filelist)
|
||||||
|
|
||||||
def extract(self, targetdir):
|
def extract(self, targetdir):
|
||||||
|
print "\n" + targetdir + "\n"
|
||||||
if self.compressor == 'rar':
|
if self.compressor == 'rar':
|
||||||
self.extractCBR(targetdir)
|
self.extractCBR(targetdir)
|
||||||
elif self.compressor == 'zip':
|
elif self.compressor == 'zip':
|
||||||
|
|||||||
Reference in New Issue
Block a user