Skip to content

Commit

Permalink
Browse: only include size attr for files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sevein committed Jul 18, 2019
1 parent b1bf656 commit 952c58d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions storage_service/locations/models/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 952c58d

Please sign in to comment.