File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ impl Reader {
218218 pub async fn new < P : AsRef < Path > > ( path : P ) -> Result < Self > {
219219 let opts = SqliteConnectOptions :: new ( )
220220 . journal_mode ( SqliteJournalMode :: Delete )
221- . filename ( path. as_ref ( ) ) ;
221+ . filename ( path) ;
222222
223223 let pool = SqlitePool :: connect_with ( opts) . await ?;
224224
@@ -341,15 +341,14 @@ pub struct Writer {
341341impl Writer {
342342 /// create a new mkondo writer
343343 pub async fn new < P : AsRef < Path > > ( path : P ) -> Result < Self > {
344- tokio:: fs:: OpenOptions :: default ( )
345- . write ( true )
346- . truncate ( true )
347- . create ( true )
348- . open ( & path)
349- . await ?;
344+ let _ = tokio:: fs:: remove_file ( & path) . await ;
350345
351- let con = format ! ( "sqlite://{}" , path. as_ref( ) . to_str( ) . unwrap( ) ) ;
352- let pool = SqlitePool :: connect ( & con) . await ?;
346+ let opts = SqliteConnectOptions :: new ( )
347+ . create_if_missing ( true )
348+ . journal_mode ( SqliteJournalMode :: Delete )
349+ . filename ( path) ;
350+
351+ let pool = SqlitePool :: connect_with ( opts) . await ?;
353352
354353 sqlx:: query ( SCHEMA ) . execute ( & pool) . await ?;
355354
You can’t perform that action at this time.
0 commit comments