mirror of
https://github.com/ciromattia/kcc
synced 2025-12-23 22:51:45 +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:
@@ -652,9 +652,19 @@ def getWorkFolder(afile):
|
|||||||
try:
|
try:
|
||||||
cbx = comicarchive.ComicArchive(afile)
|
cbx = comicarchive.ComicArchive(afile)
|
||||||
path = cbx.extract(workdir)
|
path = cbx.extract(workdir)
|
||||||
|
sanitizePermissions(path)
|
||||||
tdir = os.listdir(workdir)
|
tdir = os.listdir(workdir)
|
||||||
if 'ComicInfo.xml' in tdir:
|
is_nested_single_dir = False
|
||||||
tdir.remove('ComicInfo.xml')
|
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:
|
except OSError as e:
|
||||||
rmtree(workdir, True)
|
rmtree(workdir, True)
|
||||||
raise UserWarning(e)
|
raise UserWarning(e)
|
||||||
@@ -908,7 +918,10 @@ def detectCorruption(tmppath, orgpath):
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError('Image file %s is corrupted. Error: %s' % (pathOrg, str(err)))
|
raise RuntimeError('Image file %s is corrupted. Error: %s' % (pathOrg, str(err)))
|
||||||
else:
|
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:
|
if alreadyProcessed:
|
||||||
print("WARNING: Source files are probably created by KCC. The second conversion will decrease quality.")
|
print("WARNING: Source files are probably created by KCC. The second conversion will decrease quality.")
|
||||||
if GUI:
|
if GUI:
|
||||||
|
|||||||
Reference in New Issue
Block a user