From 5c39e7cf284a1f6e9a1657f2deb44e359fc47eb8 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 11 Jun 2026 00:54:30 +0200 Subject: chore: Move everything into one big crate That helps remove duplicated code and rustc/cargo will now also show dead code correctly. --- crates/turtle/src/sync.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 crates/turtle/src/sync.rs (limited to 'crates/turtle/src/sync.rs') diff --git a/crates/turtle/src/sync.rs b/crates/turtle/src/sync.rs new file mode 100644 index 00000000..56aef615 --- /dev/null +++ b/crates/turtle/src/sync.rs @@ -0,0 +1,34 @@ +use eyre::{Context, Result}; + +use crate::atuin_client::{ + database::Database, 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 async fn build( + settings: &Settings, + store: &SqliteStore, + db: &dyn Database, + 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(()) +} -- cgit v1.3.1