From a8bb406fde889cd11bfadb9074214c8558b85b1a Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 4 Apr 2020 21:49:54 +0800 Subject: [PATCH] add backup_count in sample --- src/config_util.rs | 4 +++- src/zip_util.rs | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/config_util.rs b/src/config_util.rs index 1ee437c..b95dd52 100644 --- a/src/config_util.rs +++ b/src/config_util.rs @@ -27,12 +27,14 @@ pub const DOT_OSS_BACKUPD_CONFIG: &str = ".oss-backupd-config.json"; }, "host": "", "encrypt_pubkey_file": "", + "backup_count": 10, "items": [ { "oss_config": null, // OPT @oss_config "target": "", "file_name": "", - "encrypt_pubkey_file": null // OPT @encrypt_pubkey_file + "encrypt_pubkey_file": null, // OPT @encrypt_pubkey_file + "backup_count": 8 } ] } diff --git a/src/zip_util.rs b/src/zip_util.rs index e84dede..4efe3f9 100644 --- a/src/zip_util.rs +++ b/src/zip_util.rs @@ -72,10 +72,7 @@ pub fn zip_file(target: &str, zip_file: &str) -> XResult<()> { pub fn get_file_name(path: &Path) -> String { match path.file_name() { - None => "no_file_name".to_string(), - Some(f) => match f.to_os_string().into_string().ok() { - None => "unknown_file_name".to_string(), - Some(f) => f, - }, + None => "no_file_name".to_owned(), + Some(f) => f.to_os_string().into_string().unwrap_or("unknown_file_name".to_owned()), } } \ No newline at end of file