backup/datastore.rs: use DateTime<Utc> to store backup time
This commit is contained in:
parent
be0084b001
commit
7ca80246ea
|
@ -8,6 +8,8 @@ use crate::backup::archive_index::*;
|
||||||
use crate::api::schema::*;
|
use crate::api::schema::*;
|
||||||
use crate::api::router::*;
|
use crate::api::router::*;
|
||||||
|
|
||||||
|
use chrono::{Utc, TimeZone};
|
||||||
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use futures::*;
|
use futures::*;
|
||||||
|
@ -115,6 +117,7 @@ fn download_catar(_parts: Parts, _req_body: Body, param: Value, _info: &ApiAsync
|
||||||
let backup_type = tools::required_string_param(¶m, "type")?;
|
let backup_type = tools::required_string_param(¶m, "type")?;
|
||||||
let backup_id = tools::required_string_param(¶m, "id")?;
|
let backup_id = tools::required_string_param(¶m, "id")?;
|
||||||
let backup_time = tools::required_integer_param(¶m, "time")?;
|
let backup_time = tools::required_integer_param(¶m, "time")?;
|
||||||
|
let backup_time = Utc.timestamp(backup_time, 0);
|
||||||
|
|
||||||
println!("Download {}.catar from {} ({}/{}/{}/{}.aidx)", archive_name, store,
|
println!("Download {}.catar from {} ({}/{}/{}/{}.aidx)", archive_name, store,
|
||||||
backup_type, backup_id, backup_time, archive_name);
|
backup_type, backup_id, backup_time, archive_name);
|
||||||
|
@ -154,4 +157,3 @@ pub fn api_method_download_catar() -> ApiAsyncMethod {
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub struct DataStore {
|
||||||
pub struct BackupInfo {
|
pub struct BackupInfo {
|
||||||
pub backup_type: String,
|
pub backup_type: String,
|
||||||
pub backup_id: String,
|
pub backup_id: String,
|
||||||
pub backup_time: i64,
|
pub backup_time: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static!{
|
lazy_static!{
|
||||||
|
@ -117,7 +117,7 @@ impl DataStore {
|
||||||
&self,
|
&self,
|
||||||
backup_type: &str,
|
backup_type: &str,
|
||||||
backup_id: &str,
|
backup_id: &str,
|
||||||
backup_time: i64,
|
backup_time: DateTime<Utc>,
|
||||||
) -> PathBuf {
|
) -> PathBuf {
|
||||||
|
|
||||||
let mut relative_path = PathBuf::new();
|
let mut relative_path = PathBuf::new();
|
||||||
|
@ -126,8 +126,7 @@ impl DataStore {
|
||||||
|
|
||||||
relative_path.push(backup_id);
|
relative_path.push(backup_id);
|
||||||
|
|
||||||
let dt = Utc.timestamp(backup_time, 0);
|
let date_str = backup_time.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||||
let date_str = dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
|
||||||
|
|
||||||
relative_path.push(&date_str);
|
relative_path.push(&date_str);
|
||||||
|
|
||||||
|
@ -190,7 +189,7 @@ impl DataStore {
|
||||||
list.push(BackupInfo {
|
list.push(BackupInfo {
|
||||||
backup_type: backup_type.to_owned(),
|
backup_type: backup_type.to_owned(),
|
||||||
backup_id: backup_id.to_owned(),
|
backup_id: backup_id.to_owned(),
|
||||||
backup_time: dt.timestamp(),
|
backup_time: dt,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue