1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 09:46:25 +00:00

Windows: Fixed possible problems with file locks

OSX: Tweaked last fix
This commit is contained in:
Paweł Jastrzębski
2014-01-23 11:23:58 +01:00
parent e4750fc965
commit 162c146bed
3 changed files with 18 additions and 12 deletions

View File

@@ -84,10 +84,10 @@ class CBxArchive:
for line in output.stdout:
if b"Everything is Ok" in line:
extracted = True
if not extracted:
raise OSError
if sys.platform.startswith('darwin'):
os.remove(self.origFileName)
if not extracted:
raise OSError
def extract(self, targetdir):
if self.compressor == 'rar':

View File

@@ -392,27 +392,36 @@ def fileImgProcess(work):
print("Splitted " + afile)
img0 = image.ComicPage(split[0], opt.profileData)
applyImgOptimization(img0, opt)
img0.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
img0.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
img1 = image.ComicPage(split[1], opt.profileData)
applyImgOptimization(img1, opt)
img1.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
img1.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
if wipe:
os.remove(os.path.join(dirpath, img0.filename))
os.remove(os.path.join(dirpath, img1.filename))
if opt.quality == 2:
img0b = image.ComicPage(split[0], opt.profileData, img0.fill)
applyImgOptimization(img0b, opt, img0)
img0b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
img0b.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
img1b = image.ComicPage(split[1], opt.profileData, img1.fill)
applyImgOptimization(img1b, opt, img1)
img1b.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
img1b.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
os.remove(os.path.join(dirpath, img0b.filename))
os.remove(os.path.join(dirpath, img1b.filename))
os.remove(img.origFileName)
else:
applyImgOptimization(img, opt)
img.saveToDir(dirpath, opt.forcepng, opt.forcecolor, wipe)
img.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
if wipe:
os.remove(os.path.join(dirpath, img.filename))
if opt.quality == 2:
img2 = image.ComicPage(os.path.join(dirpath, afile), opt.profileData, img.fill)
if img.rotated:
img2.image = img2.image.rotate(90)
img2.rotated = True
applyImgOptimization(img2, opt, img)
img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor, True)
img2.saveToDir(dirpath, opt.forcepng, opt.forcecolor)
os.remove(os.path.join(dirpath, img2.filename))
except Exception:
return str(sys.exc_info()[1])

View File

@@ -117,15 +117,13 @@ class ComicPage:
else:
self.fill = None
def saveToDir(self, targetdir, forcepng, color, wipe):
def saveToDir(self, targetdir, forcepng, color):
try:
suffix = ""
if not color and not forcepng:
self.image = self.image.convert('L')
if self.rotated:
suffix += "-kccrot"
if wipe:
os.remove(os.path.join(targetdir, self.filename))
else:
suffix += "-kcchq"
if self.noPV:
@@ -284,7 +282,6 @@ class ComicPage:
pagetwo = self.image.crop(rightbox)
pageone.save(fileone)
pagetwo.save(filetwo)
os.remove(self.origFileName)
except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
return fileone, filetwo