diff --git a/src/ytdl_sub/utils/file_handler.py b/src/ytdl_sub/utils/file_handler.py index 54c8df5d..faa7d2dc 100644 --- a/src/ytdl_sub/utils/file_handler.py +++ b/src/ytdl_sub/utils/file_handler.py @@ -389,7 +389,7 @@ class FileHandler: # This tries to prevent corrupted writes if the processed dies mid-write, atomic_dst = f"{dst_file_path}-ytdl-sub-incomplete" shutil.copyfile(src=src_file_path, dst=atomic_dst) - shutil.move(src=atomic_dst, dst=src_file_path) + shutil.move(src=atomic_dst, dst=dst_file_path) @classmethod def move(cls, src_file_path: Union[str, Path], dst_file_path: Union[str, Path]): diff --git a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py index cf34ea5e..ec155245 100644 --- a/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py +++ b/src/ytdl_sub/ytdl_additions/enhanced_download_archive.py @@ -614,6 +614,8 @@ class EnhancedDownloadArchive: self.save_file_to_output_directory( file_name=self.file_name, output_file_name=self._migrated_file_name, copy_file=True ) + FileHandler.delete(file_path=self.working_file_path) + # and delete the old one if the name differs if self._file_name != self._migrated_file_name: self.delete_file_from_output_directory(file_name=self.file_name) @@ -621,6 +623,7 @@ class EnhancedDownloadArchive: elif not self.get_file_handler_transaction_log().is_empty: self._download_mapping.to_file(output_json_file=self.working_file_path) self.save_file_to_output_directory(file_name=self.file_name, copy_file=True) + FileHandler.delete(file_path=self.working_file_path) return self def delete_file_from_output_directory(self, file_name: str):