extract_metadata: don't remove ufp files after failed extraction
Cura writes ufp files in chunks, closing the file after each chunk is written. This will result in a failed extraction, and removing the file will result in corruption. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
9e909e8532
commit
d3df568aec
|
@ -704,11 +704,13 @@ def extract_ufp(ufp_path: str, dest_path: str) -> None:
|
||||||
if not os.path.exists(dest_thumb_dir):
|
if not os.path.exists(dest_thumb_dir):
|
||||||
os.mkdir(dest_thumb_dir)
|
os.mkdir(dest_thumb_dir)
|
||||||
shutil.move(tmp_thumb_path, dest_thumb_path)
|
shutil.move(tmp_thumb_path, dest_thumb_path)
|
||||||
finally:
|
except Exception:
|
||||||
try:
|
log_to_stderr(traceback.format_exc())
|
||||||
os.remove(ufp_path)
|
sys.exit(-1)
|
||||||
except Exception:
|
try:
|
||||||
log_to_stderr(f"Error removing ufp file: {ufp_path}")
|
os.remove(ufp_path)
|
||||||
|
except Exception:
|
||||||
|
log_to_stderr(f"Error removing ufp file: {ufp_path}")
|
||||||
|
|
||||||
def main(path: str, filename: str, ufp: Optional[str]) -> None:
|
def main(path: str, filename: str, ufp: Optional[str]) -> None:
|
||||||
file_path = os.path.join(path, filename)
|
file_path = os.path.join(path, filename)
|
||||||
|
|
Loading…
Reference in New Issue