From 2c251917ce316590b29aec11b9bd8e42949a32ca Mon Sep 17 00:00:00 2001 From: "Christopher L. Crutchfield" Date: Sat, 16 Nov 2024 22:02:35 -0800 Subject: [PATCH] feat: anyhow and thiserror --- Cargo.toml | 3 +++ src/credential_manager.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40f4960..60b0718 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] +anyhow = "1.0.93" +app_dirs2 = "2.5.5" clap = "4.5.21" futures-macro = "0.3.31" keyring = { version = "3.6.1", features = ["apple-native", "windows-native", "sync-secret-service"] } rusqlite = "0.32.1" +thiserror = "2.0.3" diff --git a/src/credential_manager.rs b/src/credential_manager.rs index 322fbc0..0f75005 100644 --- a/src/credential_manager.rs +++ b/src/credential_manager.rs @@ -1,4 +1,8 @@ -use keyring::{Entry, Result}; +use std::path::PathBuf; + +use anyhow::Result; +use keyring::Entry; +use app_dirs2::{AppDataType, AppInfo, app_root}; pub struct Credential { user: String, @@ -32,10 +36,20 @@ impl CredentialManager { Ok(()) } + fn get_database_path(&self) -> Result { + let mut path = app_root(AppDataType::UserConfig, &AppInfo{ + name: "git-lfs-synology", + author: "Engineers for Exploration" + })?; + path.push("credential_store.db"); + + Ok(path) + } + fn get_entry_keyring(&self, url: &str) -> Result { let user = ""; - Entry::new(url, user) + Ok(Entry::new(url, user)?) } fn get_password(&self, url: &str) -> Result {