Fmt
This commit is contained in:
parent
eda34db508
commit
be9b5ed855
12 changed files with 43 additions and 45 deletions
|
@ -1,8 +1,8 @@
|
|||
use chrono::offset::Utc;
|
||||
use curl::{easy, easy::Easy2};
|
||||
use rand::prelude::*;
|
||||
use rusqlite::{Connection, DatabaseName};
|
||||
use ring_compat::signature::ed25519::SigningKey;
|
||||
use rusqlite::{Connection, DatabaseName};
|
||||
use tauri::{Manager, State};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
|
@ -62,7 +62,8 @@ fn data_client(file: &str) -> Result<Easy2<Collector>, ()> {
|
|||
file
|
||||
);
|
||||
client.url(&url).map_err(|_| ())?;
|
||||
client.username(include_str!("cloud_user.txt")).map_err(|_| ())?;
|
||||
client.username(include_str!("cloud_user.txt"))
|
||||
.map_err(|_| ())?;
|
||||
client.http_auth(easy::Auth::new().auto(true))
|
||||
.map_err(|_| ())?;
|
||||
client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem"))
|
||||
|
@ -76,8 +77,7 @@ fn put_client(file: &str, payload: &[u8]) -> Result<Easy2<Collector>, ()> {
|
|||
client.get_mut().1.extend_from_slice(payload);
|
||||
client.in_filesize(payload.len() as u64)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.upload(true)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
client.upload(true).map_err(|e| println!("{:?}", e))?;
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
|
@ -96,22 +96,21 @@ async fn push_key(id: &u64, key: &SigningKey) -> Result<(), ()> {
|
|||
let file = format!("{:016X}.key", id);
|
||||
let v_key = key.verifying_key();
|
||||
let client = put_client(&file, v_key.as_ref())?;
|
||||
let _perf = client.perform()
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
let _perf = client.perform().map_err(|e| println!("{:?}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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)
|
||||
let path = app
|
||||
.path()
|
||||
.resolve(&filename, tauri::path::BaseDirectory::Temp)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
db.backup(DatabaseName::Main, &path, None)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
let buf = std::fs::read(&path)
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
let buf = std::fs::read(&path).map_err(|e| println!("{:?}", e))?;
|
||||
let client = put_client(&filename, buf.as_ref())?;
|
||||
let _perf = client.perform()
|
||||
.map_err(|e| println!("{:?}", e))?;
|
||||
let _perf = client.perform().map_err(|e| println!("{:?}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue