You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2023/04/18 17:05:44 UTC
[airavata-django-portal] 05/13: AIRAVATA-3694 handle case where there is nothing to archive
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 6a52ac3c2b968f46ecd9c2cd08317a97da8c5bef
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Apr 17 17:01:02 2023 -0400
AIRAVATA-3694 handle case where there is nothing to archive
---
.../apps/admin/management/commands/archive_user_data.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/django_airavata/apps/admin/management/commands/archive_user_data.py b/django_airavata/apps/admin/management/commands/archive_user_data.py
index f9d19179..da59960f 100644
--- a/django_airavata/apps/admin/management/commands/archive_user_data.py
+++ b/django_airavata/apps/admin/management/commands/archive_user_data.py
@@ -43,10 +43,17 @@ class Command(BaseCommand):
archive_basename = f"archive_{gateway_id}_older_than_{max_age.strftime('%Y-%m-%d-%H-%M-%S')}"
archive_list_filename = f"{archive_basename}.txt"
archive_list_filepath = os.path.join(tmpdir, archive_list_filename)
+ entry_count = 0
with open(archive_list_filepath, "wt") as archive_list_file:
for entry in entries_to_archive:
+ entry_count = entry_count + 1
archive_list_file.write(f"{entry.path}\n")
+ # If nothing matching to archive, just exit
+ if entry_count == 0:
+ self.stdout.write(self.style.WARNING("Nothing to archive, exiting now"))
+ return
+
# if dry run, just print file and exit
if options['dry_run']:
self.stdout.write(f"DRY RUN: printing {archive_list_filename}, then exiting")