Skip to content

Commit d1277fb

Browse files
committed
Make the iteration of tags in the fs meta store actually streaming.
1 parent 8065c02 commit d1277fb

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/store/fs/meta.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ async fn handle_list_tags(msg: ListTagsMsg, tables: &impl ReadableTables) -> Act
301301
} = msg;
302302
let from = from.map(Bound::Included).unwrap_or(Bound::Unbounded);
303303
let to = to.map(Bound::Excluded).unwrap_or(Bound::Unbounded);
304-
let mut res = Vec::new();
305304
for item in tables.tags().range((from, to)).context(StorageSnafu)? {
306305
match item {
307306
Ok((k, v)) => {
@@ -312,23 +311,15 @@ async fn handle_list_tags(msg: ListTagsMsg, tables: &impl ReadableTables) -> Act
312311
hash: v.hash,
313312
format: v.format,
314313
};
315-
res.push(crate::api::Result::Ok(info));
314+
if tx.send(ListTagsItem::Item(info)).await.is_err() {
315+
return Ok(());
316+
}
316317
}
317318
}
318319
Err(e) => {
319-
res.push(Err(crate::api::Error::other(e)));
320-
}
321-
}
322-
}
323-
for item in res {
324-
match item {
325-
Ok(tag_info) => {
326-
if tx.send(ListTagsItem::Item(tag_info)).await.is_err() {
327-
return Ok(());
328-
}
329-
}
330-
Err(err) => {
331-
tx.send(ListTagsItem::Error(err)).await.ok();
320+
tx.send(ListTagsItem::Error(crate::api::Error::other(e)))
321+
.await
322+
.ok();
332323
return Ok(());
333324
}
334325
}

0 commit comments

Comments
 (0)