windows paths
This commit is contained in:
@@ -2,7 +2,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use lanspread_db::db::Game;
|
use lanspread_db::db::Game;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::sqlite::SqlitePool;
|
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, sqlx::FromRow)]
|
#[derive(Clone, Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||||
pub struct EtiGame {
|
pub struct EtiGame {
|
||||||
@@ -23,7 +23,8 @@ pub struct EtiGame {
|
|||||||
|
|
||||||
/// # Errors
|
/// # Errors
|
||||||
pub async fn get_games(db: &Path) -> eyre::Result<Vec<EtiGame>> {
|
pub async fn get_games(db: &Path) -> eyre::Result<Vec<EtiGame>> {
|
||||||
let pool = SqlitePool::connect(format!("sqlite:{}", db.to_string_lossy()).as_str()).await?;
|
let options = SqliteConnectOptions::new().filename(db).read_only(true);
|
||||||
|
let pool = SqlitePoolOptions::new().connect_with(options).await?;
|
||||||
|
|
||||||
let mut games = sqlx::query_as::<_, EtiGame>(
|
let mut games = sqlx::query_as::<_, EtiGame>(
|
||||||
"SELECT
|
"SELECT
|
||||||
|
|||||||
@@ -871,13 +871,17 @@ pub fn run() {
|
|||||||
|
|
||||||
if !games_folder.is_empty() {
|
if !games_folder.is_empty() {
|
||||||
// Load ETI games from the game.db resource - this MUST succeed
|
// Load ETI games from the game.db resource - this MUST succeed
|
||||||
let game_db_path = match app_handle_clone.path().resolve("game.db", tauri::path::BaseDirectory::Resource) {
|
let game_db_path =
|
||||||
Ok(path) => path,
|
match app_handle_clone
|
||||||
Err(e) => {
|
.path()
|
||||||
log::error!("Failed to resolve game.db resource: {e}");
|
.resolve("game.db", tauri::path::BaseDirectory::Resource)
|
||||||
panic!("game.db resource is mandatory - cannot continue");
|
{
|
||||||
}
|
Ok(path) => path,
|
||||||
};
|
Err(e) => {
|
||||||
|
log::error!("Failed to resolve game.db resource: {e}");
|
||||||
|
panic!("game.db resource is mandatory - cannot continue");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let eti_games = match get_games(&game_db_path).await {
|
let eti_games = match get_games(&game_db_path).await {
|
||||||
Ok(games) => {
|
Ok(games) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user