From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/6] don't truncate DateTime nanoseconds
Date: Fri, 11 Sep 2020 14:34:35 +0200 [thread overview]
Message-ID: <20200911123439.1876094-3-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20200911123439.1876094-1-f.gruenbichler@proxmox.com>
where we don't care about them anyway..
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Note: this does not change visible behaviour AFAICT, but makes the code
nicer to read IMHO..
src/backup/crypt_config.rs | 4 ++--
src/backup/key_derivation.rs | 4 ++--
src/bin/proxmox_backup_client/benchmark.rs | 4 ++--
src/bin/proxmox_backup_client/key.rs | 6 +++---
src/tools/file_logger.rs | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/backup/crypt_config.rs b/src/backup/crypt_config.rs
index 72b56dd7..c30fb5fd 100644
--- a/src/backup/crypt_config.rs
+++ b/src/backup/crypt_config.rs
@@ -10,7 +10,7 @@
use std::io::Write;
use anyhow::{bail, Error};
-use chrono::{Local, TimeZone, DateTime};
+use chrono::{Local, DateTime};
use openssl::hash::MessageDigest;
use openssl::pkcs5::pbkdf2_hmac;
use openssl::symm::{decrypt_aead, Cipher, Crypter, Mode};
@@ -219,7 +219,7 @@ impl CryptConfig {
created: DateTime<Local>,
) -> Result<Vec<u8>, Error> {
- let modified = Local.timestamp(Local::now().timestamp(), 0);
+ let modified = Local::now();
let key_config = super::KeyConfig { kdf: None, created, modified, data: self.enc_key.to_vec() };
let data = serde_json::to_string(&key_config)?.as_bytes().to_vec();
diff --git a/src/backup/key_derivation.rs b/src/backup/key_derivation.rs
index 4befe525..ac27da63 100644
--- a/src/backup/key_derivation.rs
+++ b/src/backup/key_derivation.rs
@@ -1,7 +1,7 @@
use anyhow::{bail, format_err, Context, Error};
use serde::{Deserialize, Serialize};
-use chrono::{Local, TimeZone, DateTime};
+use chrono::{Local, DateTime};
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox::try_block;
@@ -136,7 +136,7 @@ pub fn encrypt_key_with_passphrase(
enc_data.extend_from_slice(&tag);
enc_data.extend_from_slice(&encrypted_key);
- let created = Local.timestamp(Local::now().timestamp(), 0);
+ let created = Local::now();
Ok(KeyConfig {
kdf: Some(kdf),
diff --git a/src/bin/proxmox_backup_client/benchmark.rs b/src/bin/proxmox_backup_client/benchmark.rs
index 159b0c18..9830c183 100644
--- a/src/bin/proxmox_backup_client/benchmark.rs
+++ b/src/bin/proxmox_backup_client/benchmark.rs
@@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::{Error};
use serde_json::Value;
-use chrono::{TimeZone, Utc};
+use chrono::Utc;
use serde::Serialize;
use proxmox::api::{ApiMethod, RpcEnvironment};
@@ -212,7 +212,7 @@ async fn test_upload_speed(
verbose: bool,
) -> Result<(), Error> {
- let backup_time = Utc.timestamp(Utc::now().timestamp(), 0);
+ let backup_time = Utc::now();
let client = connect(repo.host(), repo.user())?;
record_repository(&repo);
diff --git a/src/bin/proxmox_backup_client/key.rs b/src/bin/proxmox_backup_client/key.rs
index f85e80c7..30afa4e5 100644
--- a/src/bin/proxmox_backup_client/key.rs
+++ b/src/bin/proxmox_backup_client/key.rs
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use anyhow::{bail, format_err, Error};
-use chrono::{Local, TimeZone};
+use chrono::Local;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
@@ -112,7 +112,7 @@ fn create(kdf: Option<Kdf>, path: Option<String>) -> Result<(), Error> {
match kdf {
Kdf::None => {
- let created = Local.timestamp(Local::now().timestamp(), 0);
+ let created = Local::now();
store_key_config(
&path,
@@ -180,7 +180,7 @@ fn change_passphrase(kdf: Option<Kdf>, path: Option<String>) -> Result<(), Error
match kdf {
Kdf::None => {
- let modified = Local.timestamp(Local::now().timestamp(), 0);
+ let modified = Local::now();
store_key_config(
&path,
diff --git a/src/tools/file_logger.rs b/src/tools/file_logger.rs
index 426e7b8d..c0fcab78 100644
--- a/src/tools/file_logger.rs
+++ b/src/tools/file_logger.rs
@@ -1,5 +1,5 @@
use anyhow::{Error};
-use chrono::{TimeZone, Local};
+use chrono::Local;
use std::io::Write;
/// Log messages with timestamps into files
@@ -56,7 +56,7 @@ impl FileLogger {
stdout.write_all(b"\n").unwrap();
}
- let line = format!("{}: {}\n", Local.timestamp(Local::now().timestamp(), 0).to_rfc3339(), msg);
+ let line = format!("{}: {}\n", Local::now().to_rfc3339(), msg);
self.file.write_all(line.as_bytes()).unwrap();
}
}
--
2.20.1
next prev parent reply other threads:[~2020-09-11 12:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 12:34 [pbs-devel] [PATCH proxmox-backup(-qemu) 0/6] improve timestamp handling Fabian Grünbichler
2020-09-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 1/6] catalog dump: preserve original mtime Fabian Grünbichler
2020-09-11 12:34 ` Fabian Grünbichler [this message]
2020-09-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 3/6] use non-panicky timestamp_opt where appropriate Fabian Grünbichler
2020-09-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 4/6] handle invalid mtime when formating entries Fabian Grünbichler
2020-09-11 12:34 ` [pbs-devel] [PATCH proxmox-backup 5/6] BackupDir: make constructor fallible Fabian Grünbichler
2020-09-11 14:12 ` Dietmar Maurer
2020-09-11 14:28 ` Dietmar Maurer
2020-09-11 12:34 ` [pbs-devel] [PATCH proxmox-backup-qemu 6/6] update to new BackupDir constructor Fabian Grünbichler
2020-09-11 14:15 ` [pbs-devel] applied: " Dietmar Maurer
2020-09-11 14:00 ` [pbs-devel] applied: [PATCH proxmox-backup(-qemu) 0/6] improve timestamp handling Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200911123439.1876094-3-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.