summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/_base.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index d98b6aaedf..e0c203cb1f 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -27,30 +27,33 @@ class ConfigError(Exception):
 class Config(object):
 
     @staticmethod
-    def parse_size(string):
+    def parse_size(value):
+        if isinstance(value, int) or isinstance(value, long):
+            return value
         sizes = {"K": 1024, "M": 1024 * 1024}
         size = 1
-        suffix = string[-1]
+        suffix = value[-1]
         if suffix in sizes:
-            string = string[:-1]
+            value = value[:-1]
             size = sizes[suffix]
-        return int(string) * size
+        return int(value) * size
 
     @staticmethod
-    def parse_duration(string):
+    def parse_duration(value):
+        if isinstance(value, int) or isinstance(value, long):
+            return value
         second = 1000
         hour = 60 * 60 * second
         day = 24 * hour
         week = 7 * day
         year = 365 * day
-
         sizes = {"s": second, "h": hour, "d": day, "w": week, "y": year}
         size = 1
-        suffix = string[-1]
+        suffix = value[-1]
         if suffix in sizes:
-            string = string[:-1]
+            value = value[:-1]
             size = sizes[suffix]
-        return int(string) * size
+        return int(value) * size
 
     @staticmethod
     def abspath(file_path):