From 952c58d0b78226f6e1180c5c6339431f8c08128e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Fri, 12 Jul 2019 09:01:24 -0700 Subject: [PATCH] Browse: only include size attr for files Nodes in the browser tree should only include the "size" property for files since the same attributes in directories is irrelevant and misleading, e.g. a directory data block usually takes 4096 bytes, but that's not something that the user needs to know. --- storage_service/locations/models/space.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage_service/locations/models/space.py b/storage_service/locations/models/space.py index b0740864d..2db786d55 100644 --- a/storage_service/locations/models/space.py +++ b/storage_service/locations/models/space.py @@ -809,8 +809,11 @@ def path2browse_dict(path): should_count = not utils.get_setting("object_counting_disabled", False) for name in entries: full_path = os.path.join(path, name) - properties[name] = {"size": os.path.getsize(full_path)} - if os.path.isdir(full_path) and os.access(full_path, os.R_OK): + properties[name] = {} + if not os.path.isdir(full_path): + properties[name]["size"] = os.path.getsize(full_path) + continue + if os.access(full_path, os.R_OK): directories.append(name) if should_count: properties[name]["object count"] = count_objects_in_directory(full_path)