Compare commits

...

2 Commits

Author SHA1 Message Date
ARAKHNID
92c5dbf4f2 Remove io import
I forgot to remove this, I'd imported io in attempts to simplify the
code and forgot it was imported.
2024-05-16 16:33:13 -05:00
ARAKHNID
3e0944d778 Simplify overwrite mode revert code
This was done because the new code is cleaner and still produces the
desired result, at least from my testing.
2024-05-16 16:30:52 -05:00

View File

@ -80,9 +80,8 @@ class Compressor():
if not self.do_new_file:
# Creates a copy of the input file
# This is done in case the output file is larger than the input file
result_item_path = Path(result_item.filename)
original_filename = Path(result_item.filename).with_stem(f"{result_item_path.stem}-og")
shutil.copy2(result_item.filename, original_filename)
temp_filename = result_item.filename + ".temp"
shutil.copy2(result_item.filename, temp_filename)
error = False
error_message = ''
@ -112,9 +111,9 @@ class Compressor():
if self.do_new_file:
shutil.copy2(result_item.filename, result_item.new_filename)
else:
shutil.copy2(original_filename, result_item.new_filename)
shutil.copy2(temp_filename, result_item.new_filename)
result_item.new_size = new_file_data.stat().st_size
original_filename.unlink(True)
Path(temp_filename).unlink(True)
else:
logging.error(str(output))