changeset 3778:7b90d7c474fa

comp file sharing: handle `admins` in quotas
author Goffi <goffi@goffi.org>
date Sun, 15 May 2022 14:15:24 +0200
parents 001ea5f4a2f9
children 89b13b405b93
files sat/plugins/plugin_comp_file_sharing.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_file_sharing.py	Sun May 15 14:14:52 2022 +0200
+++ b/sat/plugins/plugin_comp_file_sharing.py	Sun May 15 14:15:24 2022 +0200
@@ -410,13 +410,14 @@
 
     def getQuota(self, client, entity):
         """Return maximum size allowed for all files for entity"""
-        # TODO: handle special entities like admins
         quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {})
-        entity_bare_s = entity.userhost()
-        try:
-            quota = quotas["jids"][entity_bare_s]
-        except KeyError:
-            quota = quotas.get("users")
+        if self.host.memory.isAdminJID(entity):
+            quota = quotas.get("admins")
+        else:
+            try:
+                quota = quotas["jids"][entity.userhost()]
+            except KeyError:
+                quota = quotas.get("users")
         return None if quota is None else utils.parseSize(quota)
 
     async def generate_thumbnails(self, extra: dict, image_path: Path):