mirror of
https://github.com/ciromattia/kcc
synced 2026-04-24 01:49:01 +00:00
avoid orphan dir in tempdir and fix disk size check with tempdir (#1302)
* Use tempdir option for fusion path * Update makeFusion to use the same temporary directory location * Avoid creating an orphan "KCC-" in TMPDIR when --tempdir is set * Ensure disk space check follows --tempdir setting * revert some things * revert some things
This commit is contained in:
@@ -873,14 +873,18 @@ def mupdf_pdf_process_pages_parallel(filename, output_dir, target_width, target_
|
||||
|
||||
def getWorkFolder(afile, workdir=None):
|
||||
if not workdir:
|
||||
workdir = mkdtemp('', 'KCC-')
|
||||
if options.tempdir:
|
||||
workdir = mkdtemp('', 'KCC-', os.path.dirname(afile))
|
||||
else:
|
||||
workdir = mkdtemp('', 'KCC-')
|
||||
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
||||
else:
|
||||
fullPath = workdir
|
||||
check_path = gettempdir()
|
||||
if options.tempdir:
|
||||
check_path = os.path.dirname(afile)
|
||||
if os.path.isdir(afile):
|
||||
if disk_usage(gettempdir())[2] < getDirectorySize(afile) * 2.5:
|
||||
if disk_usage(check_path)[2] < getDirectorySize(afile) * 2.5:
|
||||
raise UserWarning("Not enough disk space to perform conversion.")
|
||||
try:
|
||||
copytree(afile, fullPath)
|
||||
@@ -890,7 +894,7 @@ def getWorkFolder(afile, workdir=None):
|
||||
rmtree(workdir, True)
|
||||
raise UserWarning("Failed to prepare a workspace.")
|
||||
elif os.path.isfile(afile):
|
||||
if disk_usage(gettempdir())[2] < os.path.getsize(afile) * 2.5:
|
||||
if disk_usage(check_path)[2]< os.path.getsize(afile) * 2.5:
|
||||
raise UserWarning("Not enough disk space to perform conversion.")
|
||||
if afile.lower().endswith('.pdf'):
|
||||
if not os.path.exists(fullPath):
|
||||
|
||||
Reference in New Issue
Block a user