File tree Expand file tree Collapse file tree 2 files changed +11
-14
lines changed
crates/nostr-mls-sqlite-storage/src Expand file tree Collapse file tree 2 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ impl From<refinery::Error> for Error {
40
40
}
41
41
}
42
42
43
+ impl From < std:: io:: Error > for Error {
44
+ fn from ( e : std:: io:: Error ) -> Self {
45
+ Self :: Database ( format ! ( "IO error: {}" , e) )
46
+ }
47
+ }
48
+
43
49
impl From < Error > for rusqlite:: Error {
44
50
fn from ( err : Error ) -> Self {
45
51
rusqlite:: Error :: FromSqlConversionFailure (
Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ impl NostrMlsSqliteStorage {
78
78
where
79
79
P : AsRef < Path > ,
80
80
{
81
+ // Ensure parent directory exists
82
+ if let Some ( parent) = file_path. as_ref ( ) . parent ( ) {
83
+ std:: fs:: create_dir_all ( parent) ?;
84
+ }
85
+
81
86
// Create or open the SQLite database
82
87
let mls_connection: Connection = Connection :: open ( & file_path) ?;
83
88
@@ -226,20 +231,6 @@ mod tests {
226
231
temp_dir. close ( ) . unwrap ( ) ;
227
232
}
228
233
229
- #[ test]
230
- fn test_invalid_path ( ) {
231
- let invalid_path = "/nonexistent/directory/db.sqlite" ;
232
- let storage = NostrMlsSqliteStorage :: new ( invalid_path) ;
233
- assert ! ( storage. is_err( ) ) ;
234
-
235
- if let Err ( err) = storage {
236
- match err {
237
- Error :: Rusqlite ( _) => { } // Expected error type
238
- _ => panic ! ( "Expected Rusqlite error, got {:?}" , err) ,
239
- }
240
- }
241
- }
242
-
243
234
#[ test]
244
235
fn test_openmls_storage_access ( ) {
245
236
let storage = NostrMlsSqliteStorage :: new_in_memory ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments