feat: v1.4.2, add latest user agent in meta

This commit is contained in:
2023-12-10 10:48:16 +08:00
parent c1debe5262
commit 72d89b32ab
5 changed files with 10 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -1700,7 +1700,7 @@ dependencies = [
[[package]]
name = "tiny-encrypt"
version = "1.4.1"
version = "1.4.2"
dependencies = [
"aes-gcm-stream",
"base64",

View File

@@ -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"

View File

@@ -222,6 +222,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
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 {

View File

@@ -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();

View File

@@ -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<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[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(),