mirror of
https://github.com/atuinsh/atuin.git
synced 2024-12-27 09:29:24 +01:00
fix: Make atuin account delete
void session + key (#1393)
When I deleted my Atuin.sh account, I found the command did not delete the key or session files. This caused `bail!`s from Atuin when querying the session status, or synchronising. Of course, one shouldn't expect Atuin to be able to synchronise or query with the server when the account is deleted, but the relevant files were still present, so the behaviour was different to what we'd expect. I discussed this with @ellie on Discord, and we came to the conclusion that I should open a PR, and submit a patch. I'm not sure how well this PR fits in with the borrow checker, but I've run tests, a Nix build, and a Cargo build - all goes well. I have not tested on macOS or Windows; only NixOS. Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
This commit is contained in:
parent
db70e8c52a
commit
acf6a355fd
@ -1,9 +1,11 @@
|
|||||||
use atuin_client::{api_client, settings::Settings};
|
use atuin_client::{api_client, settings::Settings};
|
||||||
use eyre::{bail, Result};
|
use eyre::{bail, Result};
|
||||||
|
use std::fs::remove_file;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub async fn run(settings: &Settings) -> Result<()> {
|
pub async fn run(settings: &Settings) -> Result<()> {
|
||||||
let session_path = settings.session_path.as_str();
|
let session_path = settings.session_path.as_str();
|
||||||
|
let key_path = settings.key_path.as_str();
|
||||||
|
|
||||||
if !PathBuf::from(session_path).exists() {
|
if !PathBuf::from(session_path).exists() {
|
||||||
bail!("You are not logged in");
|
bail!("You are not logged in");
|
||||||
@ -18,6 +20,15 @@ pub async fn run(settings: &Settings) -> Result<()> {
|
|||||||
|
|
||||||
client.delete().await?;
|
client.delete().await?;
|
||||||
|
|
||||||
|
// Fixes stale session+key when account is deleted via CLI.
|
||||||
|
if PathBuf::from(session_path).exists() {
|
||||||
|
remove_file(PathBuf::from(session_path))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if PathBuf::from(key_path).exists() {
|
||||||
|
remove_file(PathBuf::from(key_path))?;
|
||||||
|
}
|
||||||
|
|
||||||
println!("Your account is deleted");
|
println!("Your account is deleted");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user