about summary refs log tree commit diff
path: root/src/database/file
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-05-10 07:25:07 +0300
committerVika <vika@fireburn.ru>2022-05-10 07:25:07 +0300
commit1363650ee69bbeb693b99204c22c8419a716f240 (patch)
treed0215b32c6a9d4bdb3767f4dc2babed53102ee88 /src/database/file
parent05349fbd7cbeb074ec88a727a52383da99640b37 (diff)
downloadkittybox-1363650ee69bbeb693b99204c22c8419a716f240.tar.zst
FileStorage: fixes and regression tests for read_feed_with_limit
Now I will know if something breaks horribly again.
Diffstat (limited to 'src/database/file')
-rw-r--r--src/database/file/mod.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs
index 4a40f38..f9588f5 100644
--- a/src/database/file/mod.rs
+++ b/src/database/file/mod.rs
@@ -483,16 +483,20 @@ impl Storage for FileStorage {
         if let Some(feed) = self.get_post(url).await? {
             if let Some(mut feed) = filter_post(feed, user) {
                 if feed["children"].is_array() {
+                    // This code contains several clones. It looks
+                    // like the borrow checker thinks it is preventing
+                    // me from doing something incredibly stupid. The
+                    // borrow checker may or may not be right.
                     let children = feed["children"].as_array().unwrap().clone();
                     let mut posts_iter = children
                         .into_iter()
                         .map(|s: serde_json::Value| s.as_str().unwrap().to_string());
                     // Note: we can't actually use skip_while here because we end up emitting `after`.
                     // This imperative snippet consumes after instead of emitting it, allowing the
-                    // stream of posts to return only those items that truly come *after*.
+                    // stream of posts to return only those items that truly come *after*
                     if let Some(after) = after {
                         for s in posts_iter.by_ref() {
-                            if &s != after {
+                            if &s == after {
                                 break
                             }
                         }