diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2026-02-04 13:26:06 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-04 13:26:06 -0800 |
| commit | 57b542e8ed4335e5f66b5e008d9a8e90776ebffb (patch) | |
| tree | af8512d588023c09301e0505ad81653a21fad70f /crates/atuin-daemon/src/server/sync.rs | |
| parent | feat: Add a parameter to the sync to specify the download/upload page (#2408) (diff) | |
| download | atuin-57b542e8ed4335e5f66b5e008d9a8e90776ebffb.zip | |
feat: replace several files with a sqlite db (#3128)
These files have been known to have corruption issues. SQLite will
perform better across filesystems for reads/writes across threads, and
will lock as expected.
I've also put the session file in there, though I'm 50/50 on it - I'll
be replacing it with keyring storage asap anyway.
The key file is _not_ included. It should ~never be changed, and should
be easy for the user to secure + manage themselves
In the future, instead of creating more files, we can just use this as a
kv store
Resolves https://github.com/atuinsh/atuin/issues/2336, resolves
https://github.com/atuinsh/atuin/issues/1650
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
Diffstat (limited to 'crates/atuin-daemon/src/server/sync.rs')
| -rw-r--r-- | crates/atuin-daemon/src/server/sync.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/atuin-daemon/src/server/sync.rs b/crates/atuin-daemon/src/server/sync.rs index 3aa5dec3..e1e49597 100644 --- a/crates/atuin-daemon/src/server/sync.rs +++ b/crates/atuin-daemon/src/server/sync.rs @@ -21,7 +21,7 @@ pub async fn worker( tracing::info!("booting sync worker"); let encryption_key: [u8; 32] = encryption::load_key(&settings)?.into(); - let host_id = Settings::host_id().expect("failed to get host_id"); + let host_id = Settings::host_id().await?; let alias_store = AliasStore::new(store.clone(), host_id, encryption_key); let var_store = VarStore::new(store.clone(), host_id, encryption_key); @@ -38,7 +38,15 @@ pub async fn worker( ticker.tick().await; tracing::info!("sync worker tick"); - if !settings.logged_in() { + let logged_in = match settings.logged_in().await { + Ok(v) => v, + Err(e) => { + tracing::warn!("failed to check login status, skipping sync tick: {e}"); + continue; + } + }; + + if !logged_in { tracing::debug!("not logged in, skipping sync tick"); continue; } @@ -82,7 +90,7 @@ pub async fn worker( } // store sync time - tokio::task::spawn_blocking(Settings::save_sync_time).await??; + Settings::save_sync_time().await?; } } } |
