Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

realm: Use Sum(..., default=0) in currently_used_upload_space_bytes.

Alex Vandiver53d89bd1cce1
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 21972e44561..4b888bfcc09 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -1189,10 +1189,7 @@ class Realm(models.Model):
except RealmCount.DoesNotExist:
last_recorded_used_space = 0
- newly_used_space = attachments.aggregate(Sum("size"))["size__sum"]
-
- if newly_used_space is None:
- return last_recorded_used_space
+ newly_used_space = attachments.aggregate(Sum("size", default=0))["size__sum"]
return last_recorded_used_space + newly_used_space
def ensure_not_on_limited_plan(self) -> None: