aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2026-02-02 22:31:08 -0800
committerGitHub <noreply@github.com>2026-02-02 22:31:08 -0800
commit2ec0cb7fa66ea42cd129396f987dc207c6c5d9d4 (patch)
tree405dbac8fe20cee194c1e01380a774a4a7f1ab1a
parentdocs: update the `[keys]` docs (#3114) (diff)
downloadatuin-2ec0cb7fa66ea42cd129396f987dc207c6c5d9d4.zip
fix: halt sync loop if server returns an empty page (#3122)
We had an issue where the server was returning an empty page, when it should not, and causing the client to keep looping While such bugs should not happen, putting the client into a loop does not help ## Checks - [ ] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [ ] I have checked that there are no existing pull requests for the same thing
-rw-r--r--crates/atuin-client/src/record/sync.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/atuin-client/src/record/sync.rs b/crates/atuin-client/src/record/sync.rs
index 1c6b0e01..a47f100b 100644
--- a/crates/atuin-client/src/record/sync.rs
+++ b/crates/atuin-client/src/record/sync.rs
@@ -182,7 +182,6 @@ async fn sync_upload(
tag
);
- // preload with the first entry if remote does not know of this store
loop {
let page = store
.next(host, tag.as_str(), remote + progress, upload_page_size)
@@ -193,14 +192,18 @@ async fn sync_upload(
SyncError::LocalStoreError { msg: e.to_string() }
})?;
+ if page.is_empty() {
+ break;
+ }
+
client.post_records(&page).await.map_err(|e| {
error!("failed to post records: {e:?}");
SyncError::RemoteRequestError { msg: e.to_string() }
})?;
- pb.set_position(progress);
progress += page.len() as u64;
+ pb.set_position(progress);
if progress >= expected {
break;
@@ -239,13 +242,16 @@ async fn sync_download(
.with_key("eta", |state: &ProgressState, w: &mut dyn Write| write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap())
.progress_chars("#>-"));
- // preload with the first entry if remote does not know of this store
loop {
let page = client
.next_records(host, tag.clone(), local + progress, download_page_size)
.await
.map_err(|e| SyncError::RemoteRequestError { msg: e.to_string() })?;
+ if page.is_empty() {
+ break;
+ }
+
store
.push_batch(page.iter())
.await
@@ -253,8 +259,8 @@ async fn sync_download(
ret.extend(page.iter().map(|f| f.id));
- pb.set_position(progress);
progress += page.len() as u64;
+ pb.set_position(progress);
if progress >= expected {
break;