diff --git a/crates/atuin-client/src/record/sync.rs b/crates/atuin-client/src/record/sync.rs index e8d0fbf7943..ef5dfecadea 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); @@ -185,7 +185,7 @@ async fn sync_upload( // 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) + .next(host, tag.as_str(), remote + progress, page_size) .await .map_err(|e| { error!("failed to read upload page: {e:?}"); @@ -219,10 +219,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(); @@ -242,7 +242,7 @@ async fn sync_download( // 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) + .next_records(host, tag.clone(), local + progress, page_size) .await .map_err(|e| SyncError::RemoteRequestError { msg: e.to_string() })?; @@ -270,6 +270,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, @@ -293,7 +294,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, @@ -301,7 +305,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) } @@ -318,7 +324,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)) } diff --git a/crates/atuin/src/command/client/store/pull.rs b/crates/atuin/src/command/client/store/pull.rs index 36450fbf91a..4febc5d0a59 100644 --- a/crates/atuin/src/command/client/store/pull.rs +++ b/crates/atuin/src/command/client/store/pull.rs @@ -19,6 +19,11 @@ pub struct Pull { /// This will first wipe the local store, and then download all records from the remote #[arg(long, default_value = "false")] pub force: bool, + + /// Page Size + /// How many records to upload at once. Defaults to 100 + #[arg(long, default_value = "100")] + pub page: u64, } impl Pull { @@ -67,7 +72,7 @@ impl Pull { }) .collect(); - let (_, downloaded) = sync::sync_remote(operations, &store, settings).await?; + let (_, downloaded) = sync::sync_remote(operations, &store, settings, self.page).await?; println!("Downloaded {} records", downloaded.len()); diff --git a/crates/atuin/src/command/client/store/push.rs b/crates/atuin/src/command/client/store/push.rs index e1d80ef7a65..531d96d25a4 100644 --- a/crates/atuin/src/command/client/store/push.rs +++ b/crates/atuin/src/command/client/store/push.rs @@ -25,6 +25,11 @@ pub struct Push { /// local store #[arg(long, default_value = "false")] pub force: bool, + + /// Page Size + /// How many records to upload at once. Defaults to 100 + #[arg(long, default_value = "100")] + pub page: u64, } impl Push { @@ -87,7 +92,7 @@ impl Push { }) .collect(); - let (uploaded, _) = sync::sync_remote(operations, &store, settings).await?; + let (uploaded, _) = sync::sync_remote(operations, &store, settings, self.page).await?; println!("Uploaded {uploaded} records");