Skip to content

Commit bd8f330

Browse files
fix: saved filters load issue on server restart
issue: server checks the version of all filters and migrates if version is v1 if v2 (current version), it again calculates hash of the user_id from json and puts the json back in storage and load to memory fix: if v2, load to memory
1 parent 98dd0f4 commit bd8f330

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

server/src/users/filters.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,9 @@ impl Filters {
111111
this.push(filter);
112112
}
113113
}
114-
} else if let (Some(user_id), Some(stream_name), Some(filter_id)) =
115-
(user_id, stream_name, filter_id)
116-
{
117-
let path = filter_path(
118-
&get_hash(user_id),
119-
stream_name,
120-
&format!("{}.json", filter_id),
121-
);
122-
let filter_bytes = to_bytes(&filter_value);
123-
store.put_object(&path, filter_bytes.clone()).await?;
124-
if let Ok(filter) = serde_json::from_slice::<Filter>(&filter) {
125-
this.retain(|f: &Filter| f.filter_id != filter.filter_id);
126-
this.push(filter);
127-
}
114+
} else if let Ok(filter) = serde_json::from_slice::<Filter>(&filter) {
115+
this.retain(|f: &Filter| f.filter_id != filter.filter_id);
116+
this.push(filter);
128117
}
129118
}
130119
}

0 commit comments

Comments
 (0)