setting home path now works
This commit is contained in:
parent
75d172fc3f
commit
2ac3c9a45a
16 changed files with 764 additions and 71 deletions
|
|
@ -6,14 +6,13 @@ use std::{
|
|||
|
||||
use sqlx::{migrate::MigrateDatabase, Sqlite, SqlitePool};
|
||||
use tauri::{ipc::RuntimeCapability, App, AssetResolver, Manager, Url};
|
||||
|
||||
async fn populate_file_db(db: &SqlitePool) {}
|
||||
#[tauri::command]
|
||||
pub async fn initialize_database(
|
||||
app_handle: tauri::AppHandle,
|
||||
basepath: String,
|
||||
pathtemplate: String,
|
||||
) {
|
||||
println!("hello");
|
||||
let db_path = Path::new("Documents")
|
||||
.join(Path::new("Knowledgebase"))
|
||||
.join("db.sqlite");
|
||||
|
|
@ -31,27 +30,24 @@ pub async fn initialize_database(
|
|||
.await
|
||||
.unwrap_or(false)
|
||||
{
|
||||
println!("Creating database {}", unicode_db_path);
|
||||
match Sqlite::create_database(&unicode_db_path).await {
|
||||
Ok(_) => println!("Create db success"),
|
||||
Err(error) => panic!("error: {}", error),
|
||||
}
|
||||
} else {
|
||||
println!("Database already exists");
|
||||
}
|
||||
let db = SqlitePool::connect(unicode_db_path).await.unwrap();
|
||||
let result = sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS files
|
||||
(
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
relative_path TEXT NOT NULL
|
||||
relative_path TEXT NOT NULL,
|
||||
file_name TEXT NOT NULL
|
||||
);",
|
||||
)
|
||||
.execute(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("Create file table result: {:?}", result);
|
||||
let result = sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS file_diffs
|
||||
(
|
||||
|
|
@ -65,7 +61,6 @@ pub async fn initialize_database(
|
|||
.execute(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("Create diff table result: {:?}", result);
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue