From 26705d1506ed2fe10276b232b15ec12ae6b5ea8e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 29 May 2012 02:46:30 -0400 Subject: [PATCH] Catch OSError exception when calculating document filesystem stats --- apps/documents/statistics.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/documents/statistics.py b/apps/documents/statistics.py index 557a0c52dd..5c4eb46773 100644 --- a/apps/documents/statistics.py +++ b/apps/documents/statistics.py @@ -21,16 +21,20 @@ def get_used_size(path, file_list): def storage_count(path=u'.'): - directories, files = STORAGE_BACKEND().listdir(path) - total_count = len(files) - total_size = get_used_size(path, files) + try: + directories, files = STORAGE_BACKEND().listdir(path) + except OSError: + return 0, 0 + else: + total_count = len(files) + total_size = get_used_size(path, files) - for directory in directories: - file_count, files_size = storage_count(directory) - total_count += file_count - total_size += files_size + for directory in directories: + file_count, files_size = storage_count(directory) + total_count += file_count + total_size += files_size - return total_count, total_size + return total_count, total_size def get_statistics():