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/26 13:23:42 UTC

[airavata-django-portal] branch staging updated: AIRAVATA-3694 handle case where file was already deleted

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git


The following commit(s) were added to refs/heads/staging by this push:
     new 8db03aa7 AIRAVATA-3694 handle case where file was already deleted
8db03aa7 is described below

commit 8db03aa7458118819801a3371866cd08a0a172ef
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Apr 26 09:23:34 2023 -0400

    AIRAVATA-3694 handle case where file was already deleted
    
    This is to handle the case where a user directory is symlinked as an alias
    and the files to delete end up listed more than once. Code just emits a warning
    when this happens.
---
 django_airavata/apps/admin/management/commands/archive_user_data.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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 a79b1bcc..bab8be53 100644
--- a/django_airavata/apps/admin/management/commands/archive_user_data.py
+++ b/django_airavata/apps/admin/management/commands/archive_user_data.py
@@ -104,8 +104,10 @@ class Command(BaseCommand):
                             archive_path = archive_path.strip()
                             if os.path.isfile(archive_path):
                                 os.remove(archive_path)
-                            else:
+                            elif os.path.isdir(archive_path):
                                 shutil.rmtree(archive_path)
+                            else:
+                                self.stdout.write(self.style.WARNING(f"Cannot delete {archive_path} as it is neither a file nor directory, perhaps was already removed"))
                             archive_entry = models.UserDataArchiveEntry(user_data_archive=user_data_archive, entry_path=archive_path)
                             archive_entry.save()
             except Exception as e: