mirror of
https://github.com/ciromattia/kcc
synced 2025-12-23 22:51:45 +00:00
Improved 7zip detection
This commit is contained in:
@@ -27,6 +27,7 @@ from subprocess import STDOUT, PIPE
|
|||||||
from psutil import Popen
|
from psutil import Popen
|
||||||
from shutil import move, copy
|
from shutil import move, copy
|
||||||
from . import rarfile
|
from . import rarfile
|
||||||
|
from .shared import check7ZFile as is_7zfile
|
||||||
|
|
||||||
|
|
||||||
class CBxArchive:
|
class CBxArchive:
|
||||||
@@ -36,7 +37,7 @@ class CBxArchive:
|
|||||||
self.compressor = 'zip'
|
self.compressor = 'zip'
|
||||||
elif rarfile.is_rarfile(origFileName):
|
elif rarfile.is_rarfile(origFileName):
|
||||||
self.compressor = 'rar'
|
self.compressor = 'rar'
|
||||||
elif origFileName.endswith('.7z') or origFileName.endswith('.cb7'):
|
elif is_7zfile(origFileName):
|
||||||
self.compressor = '7z'
|
self.compressor = '7z'
|
||||||
else:
|
else:
|
||||||
self.compressor = None
|
self.compressor = None
|
||||||
|
|||||||
@@ -52,3 +52,9 @@ def md5Checksum(filePath):
|
|||||||
break
|
break
|
||||||
m.update(data)
|
m.update(data)
|
||||||
return m.hexdigest()
|
return m.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def check7ZFile(filePath):
|
||||||
|
with open(filePath, 'rb') as fh:
|
||||||
|
header = fh.read(6)
|
||||||
|
return header == b"7z\xbc\xaf'\x1c"
|
||||||
Reference in New Issue
Block a user