Skip to content

Commit 437184f

Browse files
committed
fix the open options
1 parent b303100 commit 437184f

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/fungi/meta.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff 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 {
341341
impl 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

0 commit comments

Comments
 (0)