This commit is contained in:
Bianca Fürstenau 2025-02-12 04:35:23 +01:00
parent ce3a2850ce
commit d7d6a32334
6 changed files with 72 additions and 35 deletions

38
src-tauri/Cargo.lock generated
View file

@ -2,6 +2,25 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "NEIN"
version = "0.1.0"
dependencies = [
"chrono",
"curl",
"openssl",
"rand 0.8.5",
"ring-compat",
"rusqlite",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-fs",
"tauri-plugin-opener",
"tokio",
]
[[package]]
name = "addr2line"
version = "0.24.2"
@ -304,25 +323,6 @@ dependencies = [
"serde",
]
[[package]]
name = "bkbh"
version = "0.1.0"
dependencies = [
"chrono",
"curl",
"openssl",
"rand 0.8.5",
"ring-compat",
"rusqlite",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-fs",
"tauri-plugin-opener",
"tokio",
]
[[package]]
name = "block"
version = "0.1.6"

View file

@ -1,7 +1,7 @@
[package]
name = "bkbh"
name = "NEIN"
version = "0.1.0"
description = "A Tauri App"
description = "Buchhaltung für „Darmstadt sagt Nein zur Bezahlkarte!“"
authors = ["Bianca Fürstenau"]
edition = "2021"

View file

@ -101,13 +101,15 @@ async fn push_key(id: &u64, key: &SigningKey) -> Result<(), ()> {
Ok(())
}
fn push_db(id: &u64, db: &Connection) -> Result<(), ()> {
let file = format!("{:016X}.sqlite", id);
db.backup(DatabaseName::Main, "tmp.sqlite", None)
fn push_db(id: &u64, db: &Connection, app: tauri::AppHandle) -> Result<(), ()> {
let filename = format!("{:016X}.sqlite", id);
let path = app.path().resolve(&filename, tauri::path::BaseDirectory::Temp)
.map_err(|e| println!("{:?}", e))?;
let buf = std::fs::read("tmp.sqlite")
db.backup(DatabaseName::Main, &path, None)
.map_err(|e| println!("{:?}", e))?;
let mut client = put_client(&file, buf.as_ref())?;
let buf = std::fs::read(&path)
.map_err(|e| println!("{:?}", e))?;
let mut client = put_client(&filename, buf.as_ref())?;
let perf = client.perform()
.map_err(|e| println!("{:?}", e))?;
Ok(())
@ -115,10 +117,11 @@ fn push_db(id: &u64, db: &Connection) -> Result<(), ()> {
#[tauri::command]
pub async fn push_data(
app: tauri::AppHandle,
state: State<'_, Mutex<AppState>>,
) -> Result<(), ()> {
let state = state.lock().await;
push_key(&state.id, &state.key).await?;
push_db(&state.id, &state.db);
push_db(&state.id, &state.db, app);
Ok(())
}