From 96ceb253e8b40fb61ad68a08da030a7c84925271 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Wed, 4 Oct 2017 13:19:19 +0200 Subject: [PATCH] GetTotal size also return optional sum of optional file sizes --- src/Content/ContentDb.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Content/ContentDb.py b/src/Content/ContentDb.py index 13a5002f..55984728 100644 --- a/src/Content/ContentDb.py +++ b/src/Content/ContentDb.py @@ -91,7 +91,7 @@ class ContentDb(Db): "size": size, "size_files": sum([val["size"] for key, val in content.get("files", {}).iteritems()]), "size_files_optional": sum([val["size"] for key, val in content.get("files_optional", {}).iteritems()]), - "modified": int(content["modified"]) + "modified": int(content.get("modified", 0)) }, { "site_id": self.site_ids.get(site.address, 0), "inner_path": inner_path @@ -116,15 +116,15 @@ class ContentDb(Db): params = {"site_id": self.site_ids.get(site.address, 0)} if ignore: params["not__inner_path"] = ignore - res = self.execute("SELECT SUM(size) + SUM(size_files) AS size FROM content WHERE ?", params) - return res.fetchone()["size"] + res = self.execute("SELECT SUM(size) + SUM(size_files) AS size, SUM(size_files_optional) AS size_optional FROM content WHERE ?", params) + row = dict(res.fetchone()) - def getOptionalSize(self, site): - res = self.execute( - "SELECT SUM(size_files_optional) AS size FROM content WHERE ?", - {"site_id": self.site_ids.get(site.address, 0)} - ) - return res.fetchone()["size"] + if not row["size"]: + row["size"] = 0 + if not row["size_optional"]: + row["size_optional"] = 0 + + return row["size"], row["size_optional"] def listModified(self, site, since): res = self.execute(