From 65ec626573f02a2d6381a9e49bc40d1bdfbb09d6 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 14 Dec 2021 11:11:05 -0800 Subject: [PATCH] Don't trim stream if max length is unset --- bookwyrm/redis_store.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/redis_store.py b/bookwyrm/redis_store.py index 78f373a2e..3b1b54a4b 100644 --- a/bookwyrm/redis_store.py +++ b/bookwyrm/redis_store.py @@ -27,7 +27,8 @@ class RedisStore(ABC): # add the status to the feed pipeline.zadd(store, value) # trim the store - pipeline.zremrangebyrank(store, 0, -1 * self.max_length) + if self.max_length: + pipeline.zremrangebyrank(store, 0, -1 * self.max_length) if not execute: return pipeline # and go! @@ -46,7 +47,7 @@ class RedisStore(ABC): pipeline = r.pipeline() for obj in objs[: self.max_length]: pipeline.zadd(store, self.get_value(obj)) - if objs: + if objs and self.max_length: pipeline.zremrangebyrank(store, 0, -1 * self.max_length) pipeline.execute() @@ -70,7 +71,7 @@ class RedisStore(ABC): pipeline.zadd(store, self.get_value(obj)) # only trim the store if objects were added - if queryset.exists(): + if queryset.exists() and self.max_length: pipeline.zremrangebyrank(store, 0, -1 * self.max_length) pipeline.execute()