avoid chrono dependency, depend on proxmox 0.3.8

- remove chrono dependency

- depend on proxmox 0.3.8

- remove epoch_now, epoch_now_u64 and epoch_now_f64

- remove tm_editor (moved to proxmox crate)

- use new helpers from proxmox 0.3.8
  * epoch_i64 and epoch_f64
  * parse_rfc3339
  * epoch_to_rfc3339_utc
  * strftime_local

- BackupDir changes:
  * store epoch and rfc3339 string instead of DateTime
  * backup_time_to_string now return a Result
  * remove unnecessary TryFrom<(BackupGroup, i64)> for BackupDir

- DynamicIndexHeader: change ctime to i64

- FixedIndexHeader: change ctime to i64
This commit is contained in:
Dietmar Maurer
2020-09-12 15:10:47 +02:00
parent 58169da46a
commit 6a7be83efe
37 changed files with 198 additions and 380 deletions

View File

@ -4,7 +4,6 @@ use std::fs::File;
use std::sync::Arc;
use std::os::unix::fs::OpenOptionsExt;
use chrono::{DateTime, Utc};
use futures::future::AbortHandle;
use serde_json::{json, Value};
@ -41,14 +40,14 @@ impl BackupReader {
datastore: &str,
backup_type: &str,
backup_id: &str,
backup_time: DateTime<Utc>,
backup_time: i64,
debug: bool,
) -> Result<Arc<BackupReader>, Error> {
let param = json!({
"backup-type": backup_type,
"backup-id": backup_id,
"backup-time": backup_time.timestamp(),
"backup-time": backup_time,
"store": datastore,
"debug": debug,
});

View File

@ -4,7 +4,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use anyhow::{bail, format_err, Error};
use chrono::{DateTime, Utc};
use futures::*;
use futures::stream::Stream;
use futures::future::AbortHandle;
@ -51,7 +50,7 @@ impl BackupWriter {
datastore: &str,
backup_type: &str,
backup_id: &str,
backup_time: DateTime<Utc>,
backup_time: i64,
debug: bool,
benchmark: bool
) -> Result<Arc<BackupWriter>, Error> {
@ -59,7 +58,7 @@ impl BackupWriter {
let param = json!({
"backup-type": backup_type,
"backup-id": backup_id,
"backup-time": backup_time.timestamp(),
"backup-time": backup_time,
"store": datastore,
"debug": debug,
"benchmark": benchmark

View File

@ -2,7 +2,6 @@ use std::io::Write;
use std::task::{Context, Poll};
use std::sync::{Arc, Mutex};
use chrono::Utc;
use anyhow::{bail, format_err, Error};
use futures::*;
use http::Uri;
@ -199,7 +198,7 @@ fn store_ticket_info(prefix: &str, server: &str, username: &str, ticket: &str, t
let mut data = file_get_json(&path, Some(json!({})))?;
let now = Utc::now().timestamp();
let now = proxmox::tools::time::epoch_i64();
data[server][username] = json!({ "timestamp": now, "ticket": ticket, "token": token});
@ -230,7 +229,7 @@ fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(Stri
// usually /run/user/<uid>/...
let path = base.place_runtime_file("tickets").ok()?;
let data = file_get_json(&path, None).ok()?;
let now = Utc::now().timestamp();
let now = proxmox::tools::time::epoch_i64();
let ticket_lifetime = tools::ticket::TICKET_LIFETIME - 60;
let uinfo = data[server][userid.as_str()].as_object()?;
let timestamp = uinfo["timestamp"].as_i64()?;