|
0 |
diff --git a/src/main.rs b/src/main.rs
|
|
1 |
index 9354d59..a2693b7 100644
|
|
2 |
--- a/src/main.rs
|
|
3 |
+++ b/src/main.rs
|
|
4 |
@@ -1169,6 +1169,19 @@ fn get_stores(config: &config::Config, home: &Option<PathBuf>) -> Result<Vec<Pas
|
|
5 |
)?);
|
|
6 |
}
|
|
7 |
}
|
|
8 |
+ } else if final_stores.len() == 0 && home.is_some() {
|
|
9 |
+ let default_path = home.clone().unwrap().join(".password_store");
|
|
10 |
+ if default_path.exists() {
|
|
11 |
+ final_stores.push(PasswordStore::new(
|
|
12 |
+ "default",
|
|
13 |
+ &Some(default_path),
|
|
14 |
+ &None,
|
|
15 |
+ home,
|
|
16 |
+ &None,
|
|
17 |
+ &CryptoImpl::GpgMe,
|
|
18 |
+ &None,
|
|
19 |
+ )?);
|
|
20 |
+ }
|
|
21 |
}
|
|
22 |
|
|
23 |
Ok(final_stores)
|
|
24 |
@@ -1176,7 +1189,7 @@ fn get_stores(config: &config::Config, home: &Option<PathBuf>) -> Result<Vec<Pas
|
|
25 |
|
|
26 |
/// Validates the config for password stores.
|
|
27 |
/// Returns a list of paths that the new store wizard should be run for
|
|
28 |
-fn validate_stores_config(settings: &config::Config) -> Vec<PathBuf> {
|
|
29 |
+fn validate_stores_config(settings: &config::Config, home: &Option<PathBuf>) -> Vec<PathBuf> {
|
|
30 |
let mut incomplete_stores: Vec<PathBuf> = vec![];
|
|
31 |
|
|
32 |
let stores_res = settings.get("stores");
|
|
33 |
@@ -1202,6 +1215,8 @@ fn validate_stores_config(settings: &config::Config) -> Vec<PathBuf> {
|
|
34 |
}
|
|
35 |
}
|
|
36 |
}
|
|
37 |
+ } else if incomplete_stores.len() == 0 && home.is_some() {
|
|
38 |
+ incomplete_stores.push(home.clone().unwrap().join(".password_store"));
|
|
39 |
}
|
|
40 |
|
|
41 |
incomplete_stores
|
|
42 |
@@ -1758,7 +1773,7 @@ fn main() {
|
|
43 |
let password_store_signing_key = std::env::var("PASSWORD_STORE_SIGNING_KEY").ok();
|
|
44 |
let xdg_config_home = match std::env::var("XDG_CONFIG_HOME") {
|
|
45 |
Err(_) => None,
|
|
46 |
- Ok(home_path) => Some(PathBuf::from(home_path)),
|
|
47 |
+ Ok(config_home_path) => Some(PathBuf::from(config_home_path)),
|
|
48 |
};
|
|
49 |
|
|
50 |
pass::read_config(
|
|
51 |
@@ -1774,7 +1789,7 @@ fn main() {
|
|
52 |
}
|
|
53 |
let (config, config_file_location) = config_res.unwrap();
|
|
54 |
|
|
55 |
- for path in validate_stores_config(&config) {
|
|
56 |
+ for path in validate_stores_config(&config, &home) {
|
|
57 |
wizard::show_init_menu(&Some(path), &home);
|
|
58 |
}
|
|
59 |
|
|
60 |
@@ -1783,7 +1798,8 @@ fn main() {
|
|
61 |
eprintln!("Error {}", err);
|
|
62 |
process::exit(1);
|
|
63 |
}
|
|
64 |
- let stores: StoreListType = Arc::new(Mutex::new(
|
|
65 |
+
|
|
66 |
+let stores: StoreListType = Arc::new(Mutex::new(
|
|
67 |
stores
|
|
68 |
.unwrap()
|
|
69 |
.into_iter()
|
|
70 |
@@ -1791,6 +1807,19 @@ fn main() {
|
|
71 |
.collect(),
|
|
72 |
));
|
|
73 |
|
|
74 |
+ if !config_file_location.exists() && stores.lock().unwrap().len() == 1 {
|
|
75 |
+ let mut config_file_dir = config_file_location.clone();
|
|
76 |
+ config_file_dir.pop();
|
|
77 |
+ if let Err(err) = std::fs::create_dir_all(config_file_dir) {
|
|
78 |
+ eprintln!("Error {err}");
|
|
79 |
+ process::exit(1);
|
|
80 |
+ }
|
|
81 |
+ if let Err(err) = pass::save_config(stores.clone(), &config_file_location) {
|
|
82 |
+ eprintln!("Error {err}");
|
|
83 |
+ process::exit(1);
|
|
84 |
+ }
|
|
85 |
+ }
|
|
86 |
+
|
|
87 |
let store: PasswordStoreType = Arc::new(Mutex::new(stores.lock().unwrap()[0].clone()));
|
|
88 |
#[allow(clippy::significant_drop_in_scrutinee)]
|
|
89 |
for ss in stores.lock().unwrap().iter() {
|