diff options
Diffstat (limited to 'crates/atuin-client/src/record')
| -rw-r--r-- | crates/atuin-client/src/record/sync.rs | 14 |
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; |
