mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 17:56:30 +00:00
Fixed tmp directories
This commit is contained in:
@@ -597,8 +597,8 @@ def genEpubStruct(path):
|
|||||||
|
|
||||||
|
|
||||||
def getWorkFolder(afile):
|
def getWorkFolder(afile):
|
||||||
if os.path.isdir(afile):
|
|
||||||
workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..'))
|
workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..'))
|
||||||
|
if os.path.isdir(afile):
|
||||||
try:
|
try:
|
||||||
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
||||||
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
||||||
@@ -610,9 +610,12 @@ def getWorkFolder(afile):
|
|||||||
raise
|
raise
|
||||||
elif afile.lower().endswith('.pdf'):
|
elif afile.lower().endswith('.pdf'):
|
||||||
pdf = pdfjpgextract.PdfJpgExtract(afile)
|
pdf = pdfjpgextract.PdfJpgExtract(afile)
|
||||||
path = pdf.extract()
|
path, njpg = pdf.extract()
|
||||||
|
if njpg == 0:
|
||||||
|
rmtree(workdir)
|
||||||
|
rmtree(path)
|
||||||
|
raise UserWarning("Failed to extract images.")
|
||||||
else:
|
else:
|
||||||
workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.splitext(afile)[0])
|
|
||||||
cbx = cbxarchive.CBxArchive(afile)
|
cbx = cbxarchive.CBxArchive(afile)
|
||||||
if cbx.isCbxFile():
|
if cbx.isCbxFile():
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -70,4 +70,4 @@ class PdfJpgExtract:
|
|||||||
|
|
||||||
njpg += 1
|
njpg += 1
|
||||||
i = iend
|
i = iend
|
||||||
return self.path
|
return self.path, njpg
|
||||||
|
|||||||
Reference in New Issue
Block a user