diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-09 21:43:23 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-09 21:43:23 +0200 |
| commit | 3223d93cb3c77ab02aa0a35f2a8314e447cee9a4 (patch) | |
| tree | 3971a1f37f5fe3cadb747c5229a0d54e868e45e3 /crates/client/src/sync.rs | |
| parent | fix(client/sync): Pass through precise error on `SyncError::WrongKey` (diff) | |
| download | atuin-3223d93cb3c77ab02aa0a35f2a8314e447cee9a4.zip | |
chore: Separate daemon, client, server, and lib into crates
Diffstat (limited to 'crates/client/src/sync.rs')
| -rw-r--r-- | crates/client/src/sync.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/crates/client/src/sync.rs b/crates/client/src/sync.rs new file mode 100644 index 00000000..abe1a201 --- /dev/null +++ b/crates/client/src/sync.rs @@ -0,0 +1,34 @@ +use eyre::{Context, Result}; + +use crate::atuin_client::database::ClientSqlite; +use crate::atuin_client::{ + history::store::HistoryStore, record::sqlite_store::SqliteStore, settings::Settings, +}; +use crate::atuin_common::record::RecordId; + +// This is the only crate that ties together all other crates. +// Therefore, it's the only crate where functions tying together all stores can live + +/// Rebuild all stores after a sync +/// Note: for history, this only does an _incremental_ sync. Hence the need to specify downloaded +/// records. +pub(crate) async fn build( + settings: &Settings, + store: &SqliteStore, + db: &ClientSqlite, + downloaded: Option<&[RecordId]>, +) -> Result<()> { + let encryption_key: [u8; 32] = crate::atuin_client::encryption::load_key(settings) + .context("could not load encryption key")? + .into(); + + let host_id = Settings::host_id().await?; + + let downloaded = downloaded.unwrap_or(&[]); + + let history_store = HistoryStore::new(store.clone(), host_id, encryption_key); + + history_store.incremental_build(db, downloaded).await?; + + Ok(()) +} |
