modified database scheme a bit. continued work on saving diffs to database
BIN
app-icon.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 119 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@1x.png
Normal file
|
After Width: | Height: | Size: 977 B |
BIN
src-tauri/icons/ios/AppIcon-20x20@2x-1.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@2x.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/ios/AppIcon-20x20@3x.png
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@1x.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@2x-1.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@2x.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/ios/AppIcon-29x29@3x.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@1x.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@2x-1.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@2x.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
src-tauri/icons/ios/AppIcon-40x40@3x.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
src-tauri/icons/ios/AppIcon-512@2x.png
Normal file
|
After Width: | Height: | Size: 207 KiB |
BIN
src-tauri/icons/ios/AppIcon-60x60@2x.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
src-tauri/icons/ios/AppIcon-60x60@3x.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src-tauri/icons/ios/AppIcon-76x76@1x.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
src-tauri/icons/ios/AppIcon-76x76@2x.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -22,7 +22,6 @@ pub enum DBError {
|
||||||
DatabaseConnectionError(String),
|
DatabaseConnectionError(String),
|
||||||
DatabaseQueryError(String),
|
DatabaseQueryError(String),
|
||||||
}
|
}
|
||||||
async fn populate_file_db(db: &SqlitePool) {}
|
|
||||||
|
|
||||||
fn get_database_path(app_handle: &tauri::AppHandle) -> Result<String, DBError> {
|
fn get_database_path(app_handle: &tauri::AppHandle) -> Result<String, DBError> {
|
||||||
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
||||||
|
|
@ -74,9 +73,11 @@ pub async fn initialize_database(app_handle: tauri::AppHandle) -> Result<(), DBE
|
||||||
"CREATE TABLE IF NOT EXISTS file_diffs
|
"CREATE TABLE IF NOT EXISTS file_diffs
|
||||||
(
|
(
|
||||||
id INTEGER NOT NULL,
|
id INTEGER NOT NULL,
|
||||||
client_id INTEGER NOT NULL,
|
client_id TEXT NOT NULL,
|
||||||
diff_text TEXT NOT NULL,
|
diff_text TEXT NOT NULL,
|
||||||
working_diff BOOLEAN,
|
working_diff BOOLEAN,
|
||||||
|
FOREIGN KEY (id)
|
||||||
|
REFERENCES file_diffs (parent_diff_id)
|
||||||
FOREIGN KEY (id)
|
FOREIGN KEY (id)
|
||||||
REFERENCES files (file_id)
|
REFERENCES files (file_id)
|
||||||
PRIMARY KEY (id, client_id)
|
PRIMARY KEY (id, client_id)
|
||||||
|
|
@ -90,16 +91,6 @@ pub async fn initialize_database(app_handle: tauri::AppHandle) -> Result<(), DBE
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
async fn store_diff(
|
|
||||||
app_handle: &tauri::AppHandle,
|
|
||||||
file_path: String,
|
|
||||||
file_name: String,
|
|
||||||
diff: String,
|
|
||||||
) -> Result<(), DBError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_file_id(
|
async fn get_file_id(
|
||||||
app_handle: &tauri::AppHandle,
|
app_handle: &tauri::AppHandle,
|
||||||
relative_file_path: &str,
|
relative_file_path: &str,
|
||||||
|
|
@ -134,18 +125,13 @@ pub async fn add_file(
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else {
|
|
||||||
println!(
|
|
||||||
"{:?}",
|
|
||||||
get_file_id(app_handle, relative_file_path, file_name).await
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
let unicode_db_path = get_database_path(&app_handle)?;
|
let unicode_db_path = get_database_path(&app_handle)?;
|
||||||
let db = SqlitePool::connect(&unicode_db_path)
|
let db = SqlitePool::connect(&unicode_db_path)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| DBError::DatabaseConnectionError(e.to_string()))?;
|
.map_err(|e| DBError::DatabaseConnectionError(e.to_string()))?;
|
||||||
|
|
||||||
let _ = sqlx::query(&format!(
|
let id = sqlx::query(&format!(
|
||||||
"
|
"
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
files (relative_path, file_name)
|
files (relative_path, file_name)
|
||||||
|
|
@ -158,3 +144,60 @@ pub async fn add_file(
|
||||||
db.close().await;
|
db.close().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
async fn get_last_file_diff(
|
||||||
|
app_handle: &tauri::AppHandle,
|
||||||
|
relative_file_path: &str,
|
||||||
|
file_name: &str,
|
||||||
|
) -> Result<i32, DBError> {
|
||||||
|
let unicode_db_path = get_database_path(&app_handle)?;
|
||||||
|
let db = SqlitePool::connect(&unicode_db_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DBError::DatabaseConnectionError(e.to_string()))?;
|
||||||
|
|
||||||
|
let (parent_diff_id, _, _, _, _, _): (i32, String, String, bool, i32, i32) =
|
||||||
|
sqlx::query_as(&format!(
|
||||||
|
"
|
||||||
|
SELECT *
|
||||||
|
FROM file_diffs
|
||||||
|
WHERE relative_path IS '{relative_file_path}'
|
||||||
|
AND file_name IS '{file_name}'
|
||||||
|
AND working_diff is 1
|
||||||
|
"
|
||||||
|
))
|
||||||
|
.fetch_one(&db)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DBError::DatabaseQueryError(e.to_string()))?;
|
||||||
|
db.close().await;
|
||||||
|
Ok(parent_diff_id)
|
||||||
|
}
|
||||||
|
#[tauri::command]
|
||||||
|
async fn store_diff(
|
||||||
|
app_handle: &tauri::AppHandle,
|
||||||
|
relative_file_path: &str,
|
||||||
|
file_name: &str,
|
||||||
|
diff: String,
|
||||||
|
) -> Result<(), DBError> {
|
||||||
|
let file_id = get_file_id(app_handle, relative_file_path, file_name)
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
DBError::DatabaseQueryError("Got file diff for non existant file".to_string())
|
||||||
|
});
|
||||||
|
|
||||||
|
let unicode_db_path = get_database_path(&app_handle)?;
|
||||||
|
let db = SqlitePool::connect(&unicode_db_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DBError::DatabaseConnectionError(e.to_string()))?;
|
||||||
|
|
||||||
|
let _ = sqlx::query(&format!(
|
||||||
|
"
|
||||||
|
INSERT INTO
|
||||||
|
file_diffs (relative_path, file_name)
|
||||||
|
VALUES
|
||||||
|
('{relative_file_path}', '{file_name}');"
|
||||||
|
))
|
||||||
|
.execute(&db)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DBError::DatabaseQueryError(e.to_string()))?;
|
||||||
|
db.close().await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||