Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fixes issue when the Redis URL also specifies a port

Trenton Holmes5b45a140b93c
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index 3271ae7e6..c11e43489 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -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=")
diff --git a/src/paperless/tests/test_settings.py b/src/paperless/tests/test_settings.py
index 346f2d098..71926542d 100644
--- a/src/paperless/tests/test_settings.py
+++ b/src/paperless/tests/test_settings.py
@@ -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)