diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index 98f7910a..76effe84 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -119,14 +119,17 @@ class UiWebsocketPlugin(object): ("css", "orange"), ("js", "purple"), ("image", "green"), - ("json", "blue"), + ("json", "darkblue"), + ("user data", "blue"), ("other", "white"), ("total", "black") ) # Collect stats size_filetypes = {} size_total = 0 - for key, content in site.content_manager.contents.iteritems(): + contents = site.content_manager.listContents() # Without user files + for inner_path in contents: + content = site.content_manager.contents[inner_path] if "files" not in content: continue for file_name, file_details in content["files"].items(): @@ -134,9 +137,19 @@ class UiWebsocketPlugin(object): ext = file_name.split(".")[-1] size_filetypes[ext] = size_filetypes.get(ext, 0) + file_details["size"] + # Get user file sizes + size_user_content = site.content_manager.contents.execute( + "SELECT SUM(size) + SUM(size_files) AS size FROM content WHERE ?", + {"not__inner_path": contents} + ).fetchone()["size"] + if not size_user_content: + size_user_content = 0 + size_filetypes["user data"] = size_user_content + size_total += size_user_content + # The missing difference is content.json sizes if "json" in size_filetypes: - size_filetypes["json"] += site.settings["size"] - size_total + size_filetypes["json"] += max(0, site.settings["size"] - size_total) size_total = size_other = site.settings["size"] # Bar @@ -144,7 +157,7 @@ class UiWebsocketPlugin(object): if extension == "total": continue if extension == "other": - size = size_other + size = max(0, size_other) elif extension == "image": size = size_filetypes.get("jpg", 0) + size_filetypes.get("png", 0) + size_filetypes.get("gif", 0) size_other -= size @@ -165,7 +178,7 @@ class UiWebsocketPlugin(object): body.append("