From 3d5a504302f4f3e5797d17d00e321cae3d3d7931 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 12 Jun 2023 11:32:10 -0500 Subject: [PATCH] fix sqlite path --- src-tauri/src/main.rs | 13 +++++++------ src-tauri/src/utils.rs | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9085a70..cd77f08 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -31,9 +31,9 @@ async fn main() -> Result<()> { // Open SRS db let srs_db_path = app_dir.join("srs_db.sqlite"); - let srs_db_path_str = srs_db_path.display().to_string(); - let srs_db_options = - SqliteConnectOptions::from_str(&srs_db_path_str)?.create_if_missing(true); + let srs_db_options = SqliteConnectOptions::new() + .filename(&srs_db_path) + .create_if_missing(true); println!("Opening srs database at {} ...", srs_db_path.display()); let srs_pool = SqlitePoolOptions::new() .connect_with(srs_db_options) @@ -58,11 +58,12 @@ async fn main() -> Result<()> { .path_resolver() .resolve_resource("./KanjiDatabase.sqlite") .expect("failed to resolve resource"); + println!("resource path: {}", resource_path.display()); // Open kanji db - let resource_path_str = resource_path.display().to_string(); - let kanji_db_options = - SqliteConnectOptions::from_str(&resource_path_str)?.read_only(true); + let kanji_db_options = SqliteConnectOptions::new() + .filename(&resource_path) + .read_only(true); let kanji_pool = SqlitePoolOptions::new().connect_lazy_with(kanji_db_options); diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 5a45052..bbc77b4 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -1,5 +1,6 @@ use std::{ ops::Add, + path::Path, time::{Duration, SystemTime, SystemTimeError, UNIX_EPOCH}, };