@@ -4,7 +4,10 @@ use std::str;
4
4
use text_io:: read;
5
5
6
6
// Internal libraries
7
- use crate :: generic:: common:: { calculate_store_name_hash, does_store_exist, get_all_secrets_from_store, get_path, write_to_file, UserMessage } ;
7
+ use crate :: generic:: common:: {
8
+ calculate_store_name_hash, does_store_exist, get_all_secrets_from_store, get_path,
9
+ write_to_file, UserMessage ,
10
+ } ;
8
11
use crate :: generic:: encryption:: { create_new_rsa_private_key, encrypt_data_with_private_key} ;
9
12
use crate :: generic:: errors:: { PasswordStoreError , Result } ;
10
13
use crate :: models:: data_model:: { Entry , EntryStore } ;
@@ -52,10 +55,11 @@ pub fn add_to_store<'a>(
52
55
let hashed_store_name = calculate_store_name_hash ( store_name) . to_string ( ) ;
53
56
let path = * get_path ( store_name) ;
54
57
// Check if there is already an entry with this name
55
- let curr_secrets = * get_all_secrets_from_store ( & path) . unwrap_or_else ( | | Box :: new ( EntryStore :: new ( ) ) ) ;
56
- for secret in curr_secrets. entries {
57
- if secret. name == entry_name{
58
- return Err ( PasswordStoreError :: ErrorEntryAlreadyExists )
58
+ let curr_secrets =
59
+ * get_all_secrets_from_store ( & path) . unwrap_or_else ( || Box :: new ( EntryStore :: new ( ) ) ) ;
60
+ for secret in curr_secrets. entries {
61
+ if secret. name == entry_name {
62
+ return Err ( PasswordStoreError :: ErrorEntryAlreadyExists ) ;
59
63
}
60
64
}
61
65
0 commit comments