[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,6 +112,9 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
for subscription, transaction_log in transaction_logs:
|
for subscription, transaction_log in transaction_logs:
|
||||||
|
if transaction_log.is_empty:
|
||||||
|
logger.info("No files changed for %s", subscription.name)
|
||||||
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Downloads for %s:\n%s\n",
|
"Downloads for %s:\n%s\n",
|
||||||
subscription.name,
|
subscription.name,
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,15 @@ class FileHandlerTransactionLog:
|
||||||
self.files_created: Dict[str, FileMetadata] = {}
|
self.files_created: Dict[str, FileMetadata] = {}
|
||||||
self.files_removed: Set[str] = set()
|
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(
|
def log_created_file(
|
||||||
self, file_name: str, file_metadata: Optional[FileMetadata] = None
|
self, file_name: str, file_metadata: Optional[FileMetadata] = None
|
||||||
) -> "FileHandlerTransactionLog":
|
) -> "FileHandlerTransactionLog":
|
||||||
|
|
|
||||||
|
|
@ -537,12 +537,13 @@ class EnhancedDownloadArchive:
|
||||||
|
|
||||||
def save_download_mappings(self) -> "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
|
Returns
|
||||||
-------
|
-------
|
||||||
self
|
self
|
||||||
"""
|
"""
|
||||||
|
if not self.get_file_handler_transaction_log().is_empty:
|
||||||
self._download_mapping.to_file(output_json_file=self._mapping_working_file_path)
|
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)
|
self.save_file_to_output_directory(file_name=self._mapping_file_name)
|
||||||
return self
|
return self
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue