Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions crates/atuin-client/src/record/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ async fn sync_upload(
tag: String,
local: RecordIdx,
remote: Option<RecordIdx>,
page_size: u64,
) -> Result<i64, SyncError> {
let remote = remote.unwrap_or(0);
let expected = local - remote;
let upload_page_size = 100;
let mut progress = 0;

let pb = ProgressBar::new(expected);
Expand All @@ -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:?}");
Expand Down Expand Up @@ -219,10 +219,10 @@ async fn sync_download(
tag: String,
local: Option<RecordIdx>,
remote: RecordIdx,
page_size: u64,
) -> Result<Vec<RecordId>, 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();

Expand All @@ -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() })?;

Expand Down Expand Up @@ -270,6 +270,7 @@ pub async fn sync_remote(
operations: Vec<Operation>,
local_store: &impl Store,
settings: &Settings,
page_size: u64,
) -> Result<(i64, Vec<RecordId>), SyncError> {
let client = Client::new(
&settings.sync_address,
Expand All @@ -293,15 +294,20 @@ 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,
tag,
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)
}

Expand All @@ -318,7 +324,7 @@ pub async fn sync(
) -> Result<(i64, Vec<RecordId>), 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))
}
Expand Down
7 changes: 6 additions & 1 deletion crates/atuin/src/command/client/store/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// How many records to upload at once. Defaults to 100
/// How many records to download at once. Defaults to 100

#[arg(long, default_value = "100")]
pub page: u64,
}

impl Pull {
Expand Down Expand Up @@ -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());

Expand Down
7 changes: 6 additions & 1 deletion crates/atuin/src/command/client/store/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");

Expand Down