1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-23 22:51:45 +00:00

Corruption detection now also delete non-image files (close #99)

This commit is contained in:
Paweł Jastrzębski
2014-07-03 09:52:59 +02:00
parent 5efb5d6dbb
commit 94f56238ae

View File

@@ -64,7 +64,6 @@ def main(argv=None):
def buildHTML(path, imgfile, imgfilepath):
imgfilepath = md5Checksum(imgfilepath)
filename = getImageFileName(imgfile)
if filename is not None:
if options.imgproc:
if "Rotated" in options.imgIndex[imgfilepath]:
rotatedPage = True
@@ -410,7 +409,7 @@ def buildEPUB(path, chapterNames, tomeNumber):
chapter = False
for afile in filenames:
filename = getImageFileName(afile)
if filename is not None and not '-kcc-hq' in filename[0]:
if not '-kcc-hq' in filename[0]:
filelist.append(buildHTML(dirpath, afile, os.path.join(dirpath, afile)))
if not chapter:
chapterlist.append((dirpath.replace('Images', 'Text'), filelist[-1][1]))
@@ -459,7 +458,6 @@ def imgDirectoryProcessing(path):
pagenumber = 0
for (dirpath, dirnames, filenames) in os.walk(path):
for afile in filenames:
if getImageFileName(afile) is not None:
pagenumber += 1
work.append([afile, dirpath, options])
if GUI:
@@ -870,6 +868,8 @@ def detectCorruption(tmpPath, orgPath):
except Exception:
rmtree(os.path.join(tmpPath, '..', '..'), True)
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
else:
os.remove(os.path.join(root, name))
def detectMargins(path):
@@ -1062,8 +1062,8 @@ def makeBook(source, qtGUI=None):
GUI.progressBarTick.emit('1')
path = getWorkFolder(source)
print("\nChecking images...")
detectCorruption(os.path.join(path, "OEBPS", "Images"), source)
getComicInfo(os.path.join(path, "OEBPS", "Images"), source)
detectCorruption(os.path.join(path, "OEBPS", "Images"), source)
if options.webtoon:
if options.customheight > 0:
comic2panel.main(['-y ' + str(options.customheight), '-i', '-m', path], qtGUI)