continued work on database
This commit is contained in:
parent
95c34fb431
commit
dcfb500a5f
1 changed files with 22 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{Error, Read, Result},
|
io::{Error, Read},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -9,12 +9,26 @@ use sqlx::{migrate::MigrateDatabase, Sqlite, SqlitePool};
|
||||||
use tauri::{ipc::RuntimeCapability, App, AssetResolver, Manager, Url};
|
use tauri::{ipc::RuntimeCapability, App, AssetResolver, Manager, Url};
|
||||||
async fn populate_file_db(db: &SqlitePool) {}
|
async fn populate_file_db(db: &SqlitePool) {}
|
||||||
|
|
||||||
|
fn get_database_path(app_handle: &tauri::AppHandle) -> Result<String, ()> {
|
||||||
|
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
||||||
|
let db_path = Path::new("Documents")
|
||||||
|
.join(Path::new("Knowledgebase"))
|
||||||
|
.join("db.sqlite");
|
||||||
|
|
||||||
|
let resolved_db_path = match app_handle
|
||||||
|
.path()
|
||||||
|
.resolve(db_path, tauri::path::BaseDirectory::Home)
|
||||||
|
{
|
||||||
|
Ok(resolved_knowledgebase_path) => resolved_knowledgebase_path,
|
||||||
|
|
||||||
|
Err(_) => return Err(()),
|
||||||
|
};
|
||||||
|
let unicode_db_path = &resolved_db_path.to_string_lossy().to_owned();
|
||||||
|
}
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn initialize_database(
|
pub async fn initialize_database(app_handle: tauri::AppHandle) {
|
||||||
app_handle: tauri::AppHandle,
|
|
||||||
basepath: String,
|
|
||||||
pathtemplate: String,
|
|
||||||
) {
|
|
||||||
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
||||||
let db_path = Path::new("Documents")
|
let db_path = Path::new("Documents")
|
||||||
.join(Path::new("Knowledgebase"))
|
.join(Path::new("Knowledgebase"))
|
||||||
|
|
@ -57,6 +71,7 @@ pub async fn initialize_database(
|
||||||
id INTEGER NOT NULL,
|
id INTEGER NOT NULL,
|
||||||
client_id INTEGER NOT NULL,
|
client_id INTEGER NOT NULL,
|
||||||
diff_text TEXT NOT NULL,
|
diff_text TEXT NOT NULL,
|
||||||
|
working_diff BOOLEAN,
|
||||||
FOREIGN KEY (id)
|
FOREIGN KEY (id)
|
||||||
REFERENCES files (file_id)
|
REFERENCES files (file_id)
|
||||||
PRIMARY KEY (id, client_id)
|
PRIMARY KEY (id, client_id)
|
||||||
|
|
@ -70,6 +85,6 @@ pub async fn initialize_database(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn store_diff(diff: String) {}
|
async fn store_diff(file_path: String, file_name: String, diff: String) {}
|
||||||
|
|
||||||
async fn add_file(file_path: String, file_name: String) {}
|
async fn add_file(file_path: String, file_name: String) {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue