Stuff
This commit is contained in:
parent
ce3a2850ce
commit
d7d6a32334
6 changed files with 72 additions and 35 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue