From 4d1568f01a0415f5113af98013b6b4383ed4f65f Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 21 Mar 2023 14:07:02 -0700 Subject: [PATCH] [BACKEND] Mark entry as deleted if all entries deleted in update --- .../downloaders/info_json/info_json_downloader.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ytdl_sub/downloaders/info_json/info_json_downloader.py b/src/ytdl_sub/downloaders/info_json/info_json_downloader.py index 244a97c1..447d760c 100644 --- a/src/ytdl_sub/downloaders/info_json/info_json_downloader.py +++ b/src/ytdl_sub/downloaders/info_json/info_json_downloader.py @@ -109,13 +109,21 @@ class InfoJsonDownloader(BaseDownloader[InfoJsonDownloaderOptions]): # If the original entry file_path is no longer maintained in the new mapping, then # delete it + num_original_files_deleted: int = 0 for file_name in self._original_entry_mappings[entry.uid].file_names: if ( entry.uid not in self._entry_mappings or file_name not in self._entry_mappings[entry.uid].file_names ): + num_original_files_deleted += 1 self._enhanced_download_archive.delete_file_from_output_directory(file_name) + # If all original entry files are deleted, mark it as deleted + if num_original_files_deleted == len( + self._original_entry_mappings[entry.uid].file_names + ): + self._enhanced_download_archive.num_entries_removed += 1 + def download(self, entry: Entry) -> Entry: """ Mock the download by copying the entry file from the output directory into