This commit is contained in:
Jesse Bannon 2024-05-10 22:13:32 -07:00
parent 2dad36e68a
commit 33540964e4
2 changed files with 4 additions and 1 deletions

View file

@ -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]):

View file

@ -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):