diff --git a/Cargo.lock b/Cargo.lock index 74e6fc2..1268869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1700,7 +1700,7 @@ dependencies = [ [[package]] name = "tiny-encrypt" -version = "1.4.1" +version = "1.4.2" dependencies = [ "aes-gcm-stream", "base64", diff --git a/Cargo.toml b/Cargo.toml index 02fc7b7..441b38f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiny-encrypt" -version = "1.4.1" +version = "1.4.2" edition = "2021" license = "MIT" description = "A simple and tiny file encrypt tool" diff --git a/src/cmd_decrypt.rs b/src/cmd_decrypt.rs index e7788d3..125cc95 100644 --- a/src/cmd_decrypt.rs +++ b/src/cmd_decrypt.rs @@ -222,6 +222,7 @@ pub fn decrypt_single(config: &Option, success!("Temp file is changed, save file ..."); drop(file_in); let mut meta = meta; + meta.latest_user_agent = Some(util::get_user_agent()); meta.file_length = temp_file_content.len() as u64; meta.file_last_modified = util_time::get_current_millis() as u64; match &mut meta.file_edit_count { diff --git a/src/cmd_info.rs b/src/cmd_info.rs index b6fb63e..746d064 100644 --- a/src/cmd_info.rs +++ b/src/cmd_info.rs @@ -76,6 +76,9 @@ pub fn info_single(path: &PathBuf, cmd_info: &CmdInfo) -> XResult<()> { infos.push(format!("{}: Version: {}, Agent: {}", header("File summary"), meta.version, meta.user_agent) ); + if let Some(latest_user_agent) = meta.latest_user_agent { + infos.push(format!("{}: {}", header("Latest user agent"), latest_user_agent)) + } let now_millis = util_time::get_current_millis() as u64; let fmt = simpledateformat::fmt(DATE_TIME_FORMAT).unwrap(); diff --git a/src/spec.rs b/src/spec.rs index f841312..20810f2 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -1,7 +1,8 @@ +use std::fs::Metadata; + use rust_util::{opt_result, util_time, XResult}; use rust_util::util_time::get_millis; use serde::{Deserialize, Serialize}; -use std::fs::Metadata; use crate::{compress, crypto_simple}; use crate::consts::SALT_META; @@ -19,6 +20,7 @@ pub struct TinyEncryptMeta { pub version: String, pub created: u64, pub user_agent: String, + pub latest_user_agent: Option, #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -170,6 +172,7 @@ impl TinyEncryptMeta { version: TINY_ENCRYPT_VERSION_11.to_string(), created: util_time::get_current_millis() as u64, user_agent: get_user_agent(), + latest_user_agent: None, comment: enc_metadata.comment.to_owned(), encrypted_comment: enc_metadata.encrypted_comment.to_owned(), encrypted_meta: enc_metadata.encrypted_meta.to_owned(),