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-client/src/database.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 '')
| -rw-r--r-- | crates/atuin-client/src/database.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs index 408e8e52..28d6c0f0 100644 --- a/crates/atuin-client/src/database.rs +++ b/crates/atuin-client/src/database.rs @@ -54,25 +54,22 @@ pub struct OptFilters { pub include_duplicates: bool, } -pub fn current_context() -> Context { - let Ok(session) = env::var("ATUIN_SESSION") else { - eprintln!( - "ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell." - ); - std::process::exit(1); - }; +pub async fn current_context() -> eyre::Result<Context> { + let session = env::var("ATUIN_SESSION").map_err(|_| { + eyre::eyre!("Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell.") + })?; let hostname = get_host_user(); let cwd = utils::get_current_dir(); - let host_id = Settings::host_id().expect("failed to load host ID"); + let host_id = Settings::host_id().await?; let git_root = utils::in_git_repo(cwd.as_str()); - Context { + Ok(Context { session, hostname, cwd, git_root, host_id: host_id.0.as_simple().to_string(), - } + }) } fn get_session_start_time(session_id: &str) -> Option<i64> { |
