diff options
author | Luke Karrys <luke@lukekarrys.com> | 2023-03-06 15:46:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-06 22:46:03 +0000 |
commit | ca5bbea0d4c4fd86eb80f99688bcb78f8ba68877 (patch) | |
tree | ec0328acc9168672ec9d4cb22d022c83a02d43b1 | |
parent | e9c5e1d85c5c1d3310fb7994c474f9462c0bca97 (diff) |
fix(client): always read session_path from settings (#757)
* fix(client): always read session_path from settings
* fixup! fix(client): always read session_path from settings
* fixup! fix(client): always read session_path from settings
-rw-r--r-- | atuin-client/src/settings.rs | 4 | ||||
-rw-r--r-- | src/command/client/sync.rs | 2 | ||||
-rw-r--r-- | src/command/client/sync/login.rs | 4 | ||||
-rw-r--r-- | src/command/client/sync/logout.rs | 12 |
4 files changed, 12 insertions, 10 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index bd47d5aa..a3d9d019 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -197,9 +197,7 @@ impl Settings { } pub fn should_sync(&self) -> Result<bool> { - let session_path = atuin_common::utils::data_dir().join("session"); - - if !self.auto_sync || !session_path.exists() { + if !self.auto_sync || !PathBuf::from(self.session_path.as_str()).exists() { return Ok(false); } diff --git a/src/command/client/sync.rs b/src/command/client/sync.rs index f71bcc99..c485e240 100644 --- a/src/command/client/sync.rs +++ b/src/command/client/sync.rs @@ -39,7 +39,7 @@ impl Cmd { match self { Self::Sync { force } => run(&settings, force, db).await, Self::Login(l) => l.run(&settings).await, - Self::Logout => logout::run(), + Self::Logout => logout::run(&settings), Self::Register(r) => r.run(&settings).await, Self::Key { base64 } => { use atuin_client::encryption::{encode_key, load_key}; diff --git a/src/command/client/sync/login.rs b/src/command/client/sync/login.rs index 06e65196..6aa2d847 100644 --- a/src/command/client/sync/login.rs +++ b/src/command/client/sync/login.rs @@ -33,9 +33,9 @@ fn get_input() -> Result<String> { impl Cmd { pub async fn run(&self, settings: &Settings) -> Result<()> { - let session_path = atuin_common::utils::data_dir().join("session"); + let session_path = settings.session_path.as_str(); - if session_path.exists() { + if PathBuf::from(session_path).exists() { println!( "You are already logged in! Please run 'atuin logout' if you wish to login again" ); diff --git a/src/command/client/sync/logout.rs b/src/command/client/sync/logout.rs index a7e9541d..90b49d6d 100644 --- a/src/command/client/sync/logout.rs +++ b/src/command/client/sync/logout.rs @@ -1,11 +1,15 @@ +use std::path::PathBuf; + use eyre::{Context, Result}; use fs_err::remove_file; -pub fn run() -> Result<()> { - let session_path = atuin_common::utils::data_dir().join("session"); +use atuin_client::settings::Settings; + +pub fn run(settings: &Settings) -> Result<()> { + let session_path = settings.session_path.as_str(); - if session_path.exists() { - remove_file(session_path.as_path()).context("Failed to remove session file")?; + if PathBuf::from(session_path).exists() { + remove_file(session_path).context("Failed to remove session file")?; println!("You have logged out!"); } else { println!("You are not logged in"); |