]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fixes issue when the Redis URL also specifies a port 2109/head
authorTrenton Holmes <797416+stumpylog@users.noreply.github.com>
Sun, 4 Dec 2022 02:30:21 +0000 (18:30 -0800)
committerTrenton Holmes <797416+stumpylog@users.noreply.github.com>
Sun, 4 Dec 2022 02:30:21 +0000 (18:30 -0800)
src/paperless/settings.py
src/paperless/tests/test_settings.py

index 3271ae7e6f2916087d02a9c362adb02d79b8a7f5..c11e434892982938a350009a1a8fe430e4b78adc 100644 (file)
@@ -78,11 +78,11 @@ def _parse_redis_url(env_redis: Optional[str]) -> Tuple[str]:
     if env_redis is None:
         return ("redis://localhost:6379", "redis://localhost:6379")
 
-    _, path = env_redis.split(":")
-
     if "unix" in env_redis.lower():
         # channels_redis socket format, looks like:
         # "unix:///path/to/redis.sock"
+        _, path = env_redis.split(":")
+        # Optionally setting a db number
         if "?db=" in env_redis:
             path, number = path.split("?db=")
             return (f"redis+socket:{path}?virtual_host={number}", env_redis)
@@ -92,6 +92,7 @@ def _parse_redis_url(env_redis: Optional[str]) -> Tuple[str]:
     elif "+socket" in env_redis.lower():
         # celery socket style, looks like:
         # "redis+socket:///path/to/redis.sock"
+        _, path = env_redis.split(":")
         if "?virtual_host=" in env_redis:
             # Virtual host (aka db number)
             path, number = path.split("?virtual_host=")
index 346f2d098a45251907e60af424da6134b554e11b..71926542d685e3da89dc85906c732872fcaa3346 100644 (file)
@@ -131,6 +131,11 @@ class TestIgnoreDateParsing(TestCase):
                     "unix:///run/redis/redis.sock?db=10",
                 ),
             ),
+            # Just a host with a port
+            (
+                "redis://myredishost:6379",
+                ("redis://myredishost:6379", "redis://myredishost:6379"),
+            ),
         ]:
             result = _parse_redis_url(input)
             self.assertTupleEqual(expected, result)