This commit is contained in:
Kovid Goyal 2023-09-16 10:59:58 +05:30
parent 7c8a20ac30
commit 14a315c4d2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -104,6 +104,7 @@ class ArchiveExtract(FileTypePlugin):
on_import = True
def run(self, archive):
import shutil
q = archive.lower()
if q.endswith('.rar'):
comic_ext = 'cbr'
@ -132,10 +133,9 @@ class ArchiveExtract(FileTypePlugin):
fnames = zf.namelist()
fnames = list(filter(fname_ok, fnames))
if is_comic(fnames):
ext = comic_ext
of = self.temporary_file('_archive_extract'+ext)
of = self.temporary_file('_archive_extract.'+comic_ext)
with closing(of), open(archive, 'rb') as f:
of.write(f.read())
shutil.copyfileobj(f, of)
return of.name
if len(fnames) > 1 or not fnames:
return archive