File tree 14 files changed +27
-37
lines changed
storage/server/src/filesystem
integration/tests/audit_trail
unit/src/tests/vault_writer
14 files changed +27
-37
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,9 @@ impl BackendAccessPoint {
29
29
}
30
30
31
31
/// Access point that mirrors to disc.
32
- pub async fn new_fs < P : AsRef < Path > > (
33
- vault : Vault ,
34
- path : P ,
35
- ) -> Result < Self > {
36
- let mirror = VaultFileWriter :: < Error > :: new ( path) . await ?;
37
- Ok ( Self ( AccessPoint :: < Error > :: new_mirror (
38
- vault,
39
- Box :: new ( mirror) ,
40
- ) ) )
32
+ pub fn new_fs < P : AsRef < Path > > ( vault : Vault , path : P ) -> Self {
33
+ let mirror = VaultFileWriter :: < Error > :: new ( path) ;
34
+ Self ( AccessPoint :: < Error > :: new_mirror ( vault, Box :: new ( mirror) ) )
41
35
}
42
36
43
37
/// Access point that mirrors to a database table.
@@ -46,8 +40,7 @@ impl BackendAccessPoint {
46
40
client : Client ,
47
41
folder_id : VaultId ,
48
42
) -> Self {
49
- let mirror =
50
- VaultDatabaseWriter :: < Error > :: new ( client, folder_id) . await ;
43
+ let mirror = VaultDatabaseWriter :: < Error > :: new ( client, folder_id) ;
51
44
Self ( AccessPoint :: < Error > :: new_mirror ( vault, Box :: new ( mirror) ) )
52
45
}
53
46
}
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ impl Folder {
63
63
vault
64
64
} ;
65
65
66
- let mirror = VaultFileWriter :: < Error > :: new ( path. as_ref ( ) ) . await ? ;
66
+ let mirror = VaultFileWriter :: < Error > :: new ( path. as_ref ( ) ) ;
67
67
let keeper =
68
68
VaultAccessPoint :: < Error > :: new_mirror ( vault, Box :: new ( mirror) ) ;
69
69
@@ -125,8 +125,7 @@ impl Folder {
125
125
event_log. apply ( vec ! [ & event] ) . await ?;
126
126
}
127
127
128
- let mirror =
129
- VaultDatabaseWriter :: < Error > :: new ( client, folder_id) . await ;
128
+ let mirror = VaultDatabaseWriter :: < Error > :: new ( client, folder_id) ;
130
129
let keeper =
131
130
VaultAccessPoint :: < Error > :: new_mirror ( vault, Box :: new ( mirror) ) ;
132
131
Original file line number Diff line number Diff line change @@ -21,15 +21,13 @@ pub enum VaultWriter {
21
21
22
22
impl VaultWriter {
23
23
/// Create a new database vault writer.
24
- pub async fn new_db ( client : Client , folder_id : VaultId ) -> Self {
25
- Self :: Database (
26
- VaultDatabaseWriter :: < Error > :: new ( client, folder_id) . await ,
27
- )
24
+ pub fn new_db ( client : Client , folder_id : VaultId ) -> Self {
25
+ Self :: Database ( VaultDatabaseWriter :: < Error > :: new ( client, folder_id) )
28
26
}
29
27
30
28
/// Create a new file system vault writer.
31
- pub async fn new_fs < P : AsRef < Path > > ( path : P ) -> Result < Self > {
32
- Ok ( Self :: FileSystem ( VaultFileWriter :: < Error > :: new ( path) . await ? ) )
29
+ pub fn new_fs < P : AsRef < Path > > ( path : P ) -> Self {
30
+ Self :: FileSystem ( VaultFileWriter :: < Error > :: new ( path) )
33
31
}
34
32
}
35
33
Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ impl AccountBackup {
453
453
let identity_vault_file = paths. identity_vault ( ) ;
454
454
455
455
let mut access =
456
- VaultFileWriter :: < Error > :: new ( identity_vault_file) . await ? ;
456
+ VaultFileWriter :: < Error > :: new ( identity_vault_file) ;
457
457
access. set_vault_name ( name. clone ( ) ) . await ?;
458
458
459
459
name
Original file line number Diff line number Diff line change 44
44
+ ' static ,
45
45
{
46
46
/// Create a new vault database writer.
47
- pub async fn new ( client : Client , folder_id : VaultId ) -> Self {
47
+ pub fn new ( client : Client , folder_id : VaultId ) -> Self {
48
48
Self {
49
49
client,
50
50
folder_id,
Original file line number Diff line number Diff line change @@ -45,12 +45,12 @@ where
45
45
+ ' static ,
46
46
{
47
47
/// Create a new vault file writer.
48
- pub async fn new < P : AsRef < Path > > ( path : P ) -> Result < Self , E > {
48
+ pub fn new < P : AsRef < Path > > ( path : P ) -> Self {
49
49
let file_path = path. as_ref ( ) . to_path_buf ( ) ;
50
- Ok ( Self {
50
+ Self {
51
51
file_path,
52
52
marker : std:: marker:: PhantomData ,
53
- } )
53
+ }
54
54
}
55
55
56
56
/// Check the identity bytes and return the byte offset of the
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ impl IdentityFolder {
152
152
. ok_or ( Error :: NoFolderPassword ( * summary. id ( ) ) ) ?;
153
153
154
154
let mut device_keeper =
155
- AccessPoint :: new_fs ( vault, & device_vault_path) . await ? ;
155
+ AccessPoint :: new_fs ( vault, & device_vault_path) ;
156
156
let key: AccessKey = device_password. into ( ) ;
157
157
device_keeper. unlock ( & key) . await ?;
158
158
@@ -219,7 +219,7 @@ impl IdentityFolder {
219
219
let mut device_keeper = if mirror {
220
220
let buffer = encode ( & vault) . await ?;
221
221
write_exclusive ( & device_vault_path, & buffer) . await ?;
222
- AccessPoint :: new_fs ( vault, & device_vault_path) . await ?
222
+ AccessPoint :: new_fs ( vault, & device_vault_path)
223
223
} else {
224
224
AccessPoint :: new_vault ( vault)
225
225
} ;
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ impl DeviceEnrollment {
126
126
// of the identity vault
127
127
if let Some ( account_name) = self . account_name . take ( ) {
128
128
let path = self . paths . identity_vault ( ) ;
129
- let mut file = VaultWriter :: new_fs ( & path) . await ? ;
129
+ let mut file = VaultWriter :: new_fs ( & path) ;
130
130
file. set_vault_name ( account_name) . await ?;
131
131
}
132
132
Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ impl ServerAccountStorage for ServerFileStorage {
403
403
) -> Result < ( ) > {
404
404
// Update the vault on disc
405
405
let vault_path = self . paths . vault_path ( id) ;
406
- let mut access = VaultWriter :: new_fs ( vault_path) . await ? ;
406
+ let mut access = VaultWriter :: new_fs ( vault_path) ;
407
407
access. set_vault_name ( name. to_owned ( ) ) . await ?;
408
408
409
409
#[ cfg( feature = "audit" ) ]
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ impl Merge for ServerFileStorage {
251
251
}
252
252
AccountEvent :: RenameAccount ( name) => {
253
253
let path = self . paths . identity_vault ( ) ;
254
- let mut file = VaultWriter :: new_fs ( path) . await ? ;
254
+ let mut file = VaultWriter :: new_fs ( path) ;
255
255
file. set_vault_name ( name. to_owned ( ) ) . await ?;
256
256
}
257
257
AccountEvent :: UpdateIdentity ( _) => {
@@ -412,7 +412,7 @@ impl Merge for ServerFileStorage {
412
412
for event in events {
413
413
if let WriteEvent :: SetVaultFlags ( flags) = event {
414
414
let path = self . paths . vault_path ( folder_id) ;
415
- let mut writer = VaultWriter :: new_fs ( path) . await ? ;
415
+ let mut writer = VaultWriter :: new_fs ( path) ;
416
416
writer. set_vault_flags ( flags) . await ?;
417
417
}
418
418
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use sos_account::{
10
10
use sos_audit:: AuditEvent ;
11
11
use sos_migrate:: import:: ImportTarget ;
12
12
use sos_sdk:: prelude:: * ;
13
- use std:: path:: { Path , PathBuf } ;
13
+ use std:: path:: PathBuf ;
14
14
15
15
#[ tokio:: test]
16
16
async fn audit_trail_client ( ) -> Result < ( ) > {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use uuid::Uuid;
10
10
async fn vault_writer_access_filesystem ( ) -> Result < ( ) > {
11
11
let ( encryption_key, _, _) = mock:: encryption_key ( ) ?;
12
12
let ( temp, vault, _) = mock:: vault_file ( ) . await ?;
13
- let mut vault_access = VaultWriter :: new_fs ( temp. path ( ) ) . await ? ;
13
+ let mut vault_access = VaultWriter :: new_fs ( temp. path ( ) ) ;
14
14
assert_encrypted_entry ( & mut vault_access, vault, & encryption_key) . await ?;
15
15
temp. close ( ) ?;
16
16
Ok ( ( ) )
@@ -23,7 +23,7 @@ async fn vault_writer_access_database() -> Result<()> {
23
23
let mut db_client = mock:: memory_database ( ) . await ?;
24
24
let vault: Vault = Default :: default ( ) ;
25
25
mock:: insert_database_vault ( & mut db_client, & vault) . await ?;
26
- let mut vault_access = VaultWriter :: new_db ( db_client, * vault. id ( ) ) . await ;
26
+ let mut vault_access = VaultWriter :: new_db ( db_client, * vault. id ( ) ) ;
27
27
assert_encrypted_entry ( & mut vault_access, vault, & encryption_key) . await ?;
28
28
Ok ( ( ) )
29
29
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ async fn vault_writer_file_del_splice() -> Result<()> {
10
10
let ( encryption_key, _, _) = mock:: encryption_key ( ) ?;
11
11
let ( temp, vault, _) = mock:: vault_file ( ) . await ?;
12
12
13
- let mut vault_access = VaultFileWriter :: < Error > :: new ( temp. path ( ) ) . await ? ;
13
+ let mut vault_access = VaultFileWriter :: < Error > :: new ( temp. path ( ) ) ;
14
14
15
15
let secrets = [
16
16
( "Note one" , "First note" ) ,
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use sos_test_utils::mock;
6
6
#[ tokio:: test]
7
7
async fn vault_writer_flags_filesystem ( ) -> Result < ( ) > {
8
8
let ( temp, _, _) = mock:: vault_file ( ) . await ?;
9
- let mut vault_access = VaultWriter :: new_fs ( temp. path ( ) ) . await ? ;
9
+ let mut vault_access = VaultWriter :: new_fs ( temp. path ( ) ) ;
10
10
test_vault_flags ( & mut vault_access) . await ?;
11
11
temp. close ( ) ?;
12
12
Ok ( ( ) )
@@ -17,7 +17,7 @@ async fn vault_writer_flags_database() -> Result<()> {
17
17
let mut db_client = mock:: memory_database ( ) . await ?;
18
18
let vault: Vault = Default :: default ( ) ;
19
19
mock:: insert_database_vault ( & mut db_client, & vault) . await ?;
20
- let mut vault_access = VaultWriter :: new_db ( db_client, * vault. id ( ) ) . await ;
20
+ let mut vault_access = VaultWriter :: new_db ( db_client, * vault. id ( ) ) ;
21
21
test_vault_flags ( & mut vault_access) . await ?;
22
22
Ok ( ( ) )
23
23
}
You can’t perform that action at this time.
0 commit comments