aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/doctor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/command/client/doctor.rs')
-rw-r--r--crates/turtle/src/command/client/doctor.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/crates/turtle/src/command/client/doctor.rs b/crates/turtle/src/command/client/doctor.rs
index 1ed90c47..eec690a5 100644
--- a/crates/turtle/src/command/client/doctor.rs
+++ b/crates/turtle/src/command/client/doctor.rs
@@ -243,15 +243,8 @@ struct SyncInfo {
}
impl SyncInfo {
- pub(crate) async fn new(settings: &Settings) -> Self {
- // Build auth state description from raw token state without calling
- // resolve_sync_auth(), which has side effects (token migration cleanup)
- // that a diagnostic command should not trigger.
- let meta = Settings::meta_store().await.ok();
- let has_cli_token = match &meta {
- Some(m) => m.session_token().await.ok().flatten().is_some(),
- None => false,
- };
+ pub(crate) async fn new(settings: &Settings) -> Result<Self> {
+ let has_cli_token = settings.have_sync_key().await?;
let auth_state = if has_cli_token {
"Self-hosted (authenticated)".into()
@@ -259,13 +252,13 @@ impl SyncInfo {
"Not authenticated".into()
};
- Self {
+ Ok(Self {
auth_state,
auto_sync: settings.auto_sync,
last_sync: Settings::last_sync()
.await
.map_or_else(|_| "no last sync".to_string(), |v| v.to_string()),
- }
+ })
}
}
@@ -318,11 +311,11 @@ struct AtuinInfo {
}
impl AtuinInfo {
- pub(crate) async fn new(settings: &Settings) -> Self {
- let logged_in = settings.logged_in().await.unwrap_or(false);
+ pub(crate) async fn new(settings: &Settings) -> Result<Self> {
+ let logged_in = settings.have_sync_key().await?;
let sync = if logged_in {
- Some(SyncInfo::new(settings).await)
+ Some(SyncInfo::new(settings).await?)
} else {
None
};
@@ -335,13 +328,13 @@ impl AtuinInfo {
Err(_) => "error".to_string(),
};
- Self {
+ Ok(Self {
version: crate::VERSION.to_string(),
commit: crate::SHA.to_string(),
sync,
sqlite_version,
setting_paths: SettingPaths::new(settings),
- }
+ })
}
}
@@ -353,12 +346,12 @@ struct DoctorDump {
}
impl DoctorDump {
- pub(crate) async fn new(settings: &Settings) -> Self {
- Self {
- atuin: AtuinInfo::new(settings).await,
+ pub(crate) async fn new(settings: &Settings) -> Result<Self> {
+ Ok(Self {
+ atuin: AtuinInfo::new(settings).await?,
shell: ShellInfo::new(),
system: SystemInfo::new(),
- }
+ })
}
}
@@ -399,7 +392,7 @@ fn checks(info: &DoctorDump) {
pub(crate) async fn run(settings: &Settings) -> Result<()> {
println!("{}", "Atuin Doctor".bold());
println!("Checking for diagnostics");
- let dump = DoctorDump::new(settings).await;
+ let dump = DoctorDump::new(settings).await?;
checks(&dump);