1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

with certain file structures: fix large file chunking, ComicInfo.xml, permissions (#819)

* fix nested folder extraction

* add comicinfo.xml handling

* sanitize

* add error handling

* space
This commit is contained in:
Alex Xu
2025-01-30 11:31:33 -08:00
committed by GitHub
parent a3546d19c3
commit 1b487c18d6

View File

@@ -652,9 +652,19 @@ def getWorkFolder(afile):
try:
cbx = comicarchive.ComicArchive(afile)
path = cbx.extract(workdir)
sanitizePermissions(path)
tdir = os.listdir(workdir)
if 'ComicInfo.xml' in tdir:
tdir.remove('ComicInfo.xml')
is_nested_single_dir = False
if len(tdir) == 2 and 'ComicInfo.xml' in tdir:
tdir.remove('ComicInfo.xml')
is_nested_single_dir = os.path.isdir(os.path.join(workdir, tdir[0]))
if is_nested_single_dir:
os.replace(
os.path.join(workdir, 'ComicInfo.xml'),
os.path.join(workdir, tdir[0], 'ComicInfo.xml')
)
if len(tdir) == 1 and is_nested_single_dir:
path = os.path.join(workdir, tdir[0])
except OSError as e:
rmtree(workdir, True)
raise UserWarning(e)
@@ -908,7 +918,10 @@ def detectCorruption(tmppath, orgpath):
else:
raise RuntimeError('Image file %s is corrupted. Error: %s' % (pathOrg, str(err)))
else:
os.remove(os.path.join(root, name))
try:
os.remove(os.path.join(root, name))
except OSError as e:
raise RuntimeError(f"{name}: {e}")
if alreadyProcessed:
print("WARNING: Source files are probably created by KCC. The second conversion will decrease quality.")
if GUI: