From 77e816869fb94b44566c3a664231e9ce212092ab Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Wed, 4 Feb 2026 03:25:36 +0100 Subject: feat: Add a parameter to the sync to specify the download/upload page (#2408) This adds a parameter to change the upload/download page size, this could help if one gets a '413' in a selfhosted scenario. ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing --------- Co-authored-by: Ellie Huxtable --- crates/atuin-client/src/record/sync.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/atuin-client/src') diff --git a/crates/atuin-client/src/record/sync.rs b/crates/atuin-client/src/record/sync.rs index a47f100b..bd357b79 100644 --- a/crates/atuin-client/src/record/sync.rs +++ b/crates/atuin-client/src/record/sync.rs @@ -163,10 +163,10 @@ async fn sync_upload( tag: String, local: RecordIdx, remote: Option, + page_size: u64, ) -> Result { let remote = remote.unwrap_or(0); let expected = local - remote; - let upload_page_size = 100; let mut progress = 0; let pb = ProgressBar::new(expected); @@ -184,7 +184,7 @@ async fn sync_upload( loop { let page = store - .next(host, tag.as_str(), remote + progress, upload_page_size) + .next(host, tag.as_str(), remote + progress, page_size) .await .map_err(|e| { error!("failed to read upload page: {e:?}"); @@ -222,10 +222,10 @@ async fn sync_download( tag: String, local: Option, remote: RecordIdx, + page_size: u64, ) -> Result, SyncError> { let local = local.unwrap_or(0); let expected = remote - local; - let download_page_size = 100; let mut progress = 0; let mut ret = Vec::new(); @@ -244,7 +244,7 @@ async fn sync_download( loop { let page = client - .next_records(host, tag.clone(), local + progress, download_page_size) + .next_records(host, tag.clone(), local + progress, page_size) .await .map_err(|e| SyncError::RemoteRequestError { msg: e.to_string() })?; @@ -276,6 +276,7 @@ pub async fn sync_remote( operations: Vec, local_store: &impl Store, settings: &Settings, + page_size: u64, ) -> Result<(i64, Vec), SyncError> { let client = Client::new( &settings.sync_address, @@ -299,7 +300,10 @@ pub async fn sync_remote( tag, local, remote, - } => uploaded += sync_upload(local_store, &client, host, tag, local, remote).await?, + } => { + uploaded += + sync_upload(local_store, &client, host, tag, local, remote, page_size).await? + } Operation::Download { host, @@ -307,7 +311,9 @@ pub async fn sync_remote( local, remote, } => { - let mut d = sync_download(local_store, &client, host, tag, local, remote).await?; + let mut d = + sync_download(local_store, &client, host, tag, local, remote, page_size) + .await?; downloaded.append(&mut d) } @@ -324,7 +330,7 @@ pub async fn sync( ) -> Result<(i64, Vec), SyncError> { let (diff, _) = diff(settings, store).await?; let operations = operations(diff, store).await?; - let (uploaded, downloaded) = sync_remote(operations, store, settings).await?; + let (uploaded, downloaded) = sync_remote(operations, store, settings, 100).await?; Ok((uploaded, downloaded)) } -- cgit v1.3.1