From 973c7b452911e6d45afd961dd7bd6376e401f79d Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 28 Jan 2020 15:28:57 -0500 Subject: [PATCH] Add sizes to file entries (fixes #5) --- chord_drop_box_service/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chord_drop_box_service/app.py b/chord_drop_box_service/app.py index fd0506e..6a7a0e9 100644 --- a/chord_drop_box_service/app.py +++ b/chord_drop_box_service/app.py @@ -54,7 +54,9 @@ def recursively_build_directory_tree(directory, level=0): "path": os.path.abspath(os.path.join(directory, entry)), "contents": recursively_build_directory_tree(os.path.join(directory, entry), level=level+1)} if os.path.isdir(os.path.join(directory, entry)) - else {"name": entry, "path": os.path.abspath(os.path.join(directory, entry))} + else {"name": entry, + "path": os.path.abspath(os.path.join(directory, entry)), + "size": os.path.getsize(os.path.join(directory, entry))} for entry in os.listdir(directory) if (level < TRAVERSAL_LIMIT or not os.path.isdir(os.path.join(directory, entry))) and entry[0] != ".")