new backup adjustments
This commit is contained in:
@@ -6,6 +6,7 @@ use alloc::string::{String, ToString};
|
||||
use chrono::DateTime;
|
||||
use edge_http::io::server::Connection;
|
||||
use edge_nal::io::{Read, Write};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
@@ -46,19 +47,11 @@ where
|
||||
T: Read + Write,
|
||||
{
|
||||
let input = read_up_to_bytes_from_request(conn, Some(4096)).await?;
|
||||
info!("Read input with length {}", input.len());
|
||||
let mut board = BOARD_ACCESS.get().await.lock().await;
|
||||
let config_to_backup = serde_json::from_slice(&input)?;
|
||||
info!("Parsed send config to object");
|
||||
board.board_hal.backup_config(&config_to_backup).await?;
|
||||
conn.initiate_response(
|
||||
200,
|
||||
Some("OK"),
|
||||
&[
|
||||
("Access-Control-Allow-Origin", "*"),
|
||||
("Access-Control-Allow-Headers", "*"),
|
||||
("Access-Control-Allow-Methods", "*"),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
Ok(Some("saved".to_owned()))
|
||||
}
|
||||
|
||||
@@ -73,6 +66,7 @@ where
|
||||
|
||||
let json = match info {
|
||||
Ok(h) => {
|
||||
info!("Got backup info: {:?}", h);
|
||||
let timestamp = DateTime::from_timestamp_millis(h.timestamp).unwrap_or_default();
|
||||
let wbh = WebBackupHeader {
|
||||
timestamp: timestamp.to_rfc3339(),
|
||||
@@ -81,6 +75,7 @@ where
|
||||
serde_json::to_string(&wbh)?
|
||||
}
|
||||
Err(err) => {
|
||||
info!("Error getting backup info: {:?}", err);
|
||||
let wbh = WebBackupHeader {
|
||||
timestamp: err.to_string(),
|
||||
size: 0,
|
||||
|
||||
Reference in New Issue
Block a user