File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
client-core/surb-storage/src/backend/fs_backend
credential-storage/src/persistent_storage Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ impl StorageManager {
37
37
. journal_mode ( sqlx:: sqlite:: SqliteJournalMode :: Wal )
38
38
. synchronous ( SqliteSynchronous :: Normal )
39
39
. auto_vacuum ( SqliteAutoVacuum :: Incremental )
40
- . filename ( & database_path)
40
+ . filename ( database_path)
41
41
. create_if_missing ( fresh)
42
42
. disable_statement_logging ( ) ;
43
43
@@ -49,8 +49,7 @@ impl StorageManager {
49
49
}
50
50
} ;
51
51
52
- let connection_pool =
53
- SqlitePoolGuard :: new ( database_path. as_ref ( ) . to_path_buf ( ) , connection_pool) ;
52
+ let connection_pool = SqlitePoolGuard :: new ( connection_pool) ;
54
53
55
54
if let Err ( err) = sqlx:: migrate!( "./fs_surbs_migrations" )
56
55
. run ( & * connection_pool)
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ impl PersistentStorage {
63
63
. journal_mode ( sqlx:: sqlite:: SqliteJournalMode :: Wal )
64
64
. synchronous ( SqliteSynchronous :: Normal )
65
65
. auto_vacuum ( SqliteAutoVacuum :: Incremental )
66
- . filename ( & database_path)
66
+ . filename ( database_path)
67
67
. create_if_missing ( true )
68
68
. disable_statement_logging ( ) ;
69
69
@@ -75,8 +75,7 @@ impl PersistentStorage {
75
75
}
76
76
} ;
77
77
78
- let connection_pool =
79
- SqlitePoolGuard :: new ( database_path. as_ref ( ) . to_path_buf ( ) , connection_pool) ;
78
+ let connection_pool = SqlitePoolGuard :: new ( connection_pool) ;
80
79
81
80
if let Err ( err) = sqlx:: migrate!( "./migrations" ) . run ( & * connection_pool) . await {
82
81
error ! ( "Failed to perform migration on the SQLx database: {err}" ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,12 @@ pub struct SqlitePoolGuard {
39
39
40
40
impl SqlitePoolGuard {
41
41
/// Create new instance providing path to database and connection pool
42
- pub fn new ( database_path : PathBuf , connection_pool : sqlx:: SqlitePool ) -> Self {
42
+ pub fn new ( connection_pool : sqlx:: SqlitePool ) -> Self {
43
+ let database_path = connection_pool
44
+ . connect_options ( )
45
+ . get_filename ( )
46
+ . to_path_buf ( ) ;
47
+
43
48
Self {
44
49
database_path,
45
50
connection_pool,
@@ -160,7 +165,7 @@ mod tests {
160
165
. await
161
166
. unwrap ( ) ;
162
167
163
- let guard = SqlitePoolGuard :: new ( database_path . clone ( ) , connection_pool) ;
168
+ let guard = SqlitePoolGuard :: new ( connection_pool) ;
164
169
assert ! (
165
170
guard
166
171
. wait_for_db_files_close( )
You can’t perform that action at this time.
0 commit comments