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 2019/05/29 22:34:10 UTC

[airavata-django-portal] 02/04: AIRAVATA-3034 Ignore broken symlinks when calculating dir size

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

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

commit 834b78daab86780ceea5d8a54928a0f6572c0ae5
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed May 29 18:30:50 2019 -0400

    AIRAVATA-3034 Ignore broken symlinks when calculating dir size
---
 django_airavata/apps/api/datastore.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/django_airavata/apps/api/datastore.py b/django_airavata/apps/api/datastore.py
index 6369d22..2707db0 100644
--- a/django_airavata/apps/api/datastore.py
+++ b/django_airavata/apps/api/datastore.py
@@ -171,5 +171,8 @@ def _get_dir_size(start_path='.'):
     for dirpath, dirnames, filenames in os.walk(start_path):
         for f in filenames:
             fp = os.path.join(dirpath, f)
-            total_size += os.path.getsize(fp)
+            # Check for broken symlinks (.exists return False for broken
+            # symlinks)
+            if os.path.exists(fp):
+                total_size += os.path.getsize(fp)
     return total_size