Fix site size calculation

This commit is contained in:
shortcutme 2016-09-04 17:44:45 +02:00
parent 1801df32a6
commit 682fa80a8a

View file

@ -606,14 +606,15 @@ class ContentManager(object):
# Checks if the content.json content is valid # Checks if the content.json content is valid
# Return: True or False # Return: True or False
def verifyContent(self, inner_path, content): def verifyContent(self, inner_path, content):
content_size = len(json.dumps(content)) + sum([file["size"] for file in content["files"].values()]) # Size of new content content_size = len(json.dumps(content, indent=1)) + sum([file["size"] for file in content["files"].values()]) # Size of new content
# Calculate old content size # Calculate old content size
old_content = self.contents.get(inner_path) old_content = self.contents.get(inner_path)
if old_content: if old_content:
old_content_size = len(json.dumps(old_content)) + sum([file["size"] for file in old_content.get("files", {}).values()]) old_content_size = len(json.dumps(old_content, indent=1)) + sum([file["size"] for file in old_content.get("files", {}).values()])
else: else:
old_content_size = 0 old_content_size = 0
content_size_optional = sum([file["size"] for file in content.get("files_optional", {}).values()]) content_size_optional = sum([file["size"] for file in content.get("files_optional", {}).values()])
site_size = self.site.settings["size"] - old_content_size + content_size # Site size without old content plus the new site_size = self.site.settings["size"] - old_content_size + content_size # Site size without old content plus the new