[BACKEND] Do not write download archive file if no files changed
This commit is contained in:
parent
47a46265cf
commit
7aca848268
3 changed files with 21 additions and 8 deletions
|
|
@ -112,11 +112,14 @@ def main():
|
|||
)
|
||||
|
||||
for subscription, transaction_log in transaction_logs:
|
||||
logger.info(
|
||||
"Downloads for %s:\n%s\n",
|
||||
subscription.name,
|
||||
transaction_log.to_output_message(subscription.output_directory),
|
||||
)
|
||||
if transaction_log.is_empty:
|
||||
logger.info("No files changed for %s", subscription.name)
|
||||
else:
|
||||
logger.info(
|
||||
"Downloads for %s:\n%s\n",
|
||||
subscription.name,
|
||||
transaction_log.to_output_message(subscription.output_directory),
|
||||
)
|
||||
|
||||
# Ran successfully, so we can delete the debug file
|
||||
Logger.cleanup(delete_debug_file=True)
|
||||
|
|
|
|||
|
|
@ -93,6 +93,15 @@ class FileHandlerTransactionLog:
|
|||
self.files_created: Dict[str, FileMetadata] = {}
|
||||
self.files_removed: Set[str] = set()
|
||||
|
||||
@property
|
||||
def is_empty(self) -> bool:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
True if no transaction logs are recorded. False otherwise
|
||||
"""
|
||||
return len(self.files_created) == 0 and len(self.files_removed) == 0
|
||||
|
||||
def log_created_file(
|
||||
self, file_name: str, file_metadata: Optional[FileMetadata] = None
|
||||
) -> "FileHandlerTransactionLog":
|
||||
|
|
|
|||
|
|
@ -537,14 +537,15 @@ class EnhancedDownloadArchive:
|
|||
|
||||
def save_download_mappings(self) -> "EnhancedDownloadArchive":
|
||||
"""
|
||||
Saves the updated download mappings to the output directory
|
||||
Saves the updated download mappings to the output directory if any files were changed.
|
||||
|
||||
Returns
|
||||
-------
|
||||
self
|
||||
"""
|
||||
self._download_mapping.to_file(output_json_file=self._mapping_working_file_path)
|
||||
self.save_file_to_output_directory(file_name=self._mapping_file_name)
|
||||
if not self.get_file_handler_transaction_log().is_empty:
|
||||
self._download_mapping.to_file(output_json_file=self._mapping_working_file_path)
|
||||
self.save_file_to_output_directory(file_name=self._mapping_file_name)
|
||||
return self
|
||||
|
||||
def save_file_to_output_directory(
|
||||
|
|
|
|||
Loading…
Reference in a new issue