opt config_util.rs

This commit is contained in:
2020-04-04 22:30:30 +08:00
parent 6f5bc06217
commit 18bf157d73

View File

@@ -125,10 +125,6 @@ fn real_make_oss_key(oss_backupd_config: &OSSBackupdConfig, oss_backupd_config_i
key
}
pub fn get_now_ymdhms() -> String {
Utc::now().format("%Y%m%d_%H%M%S").to_string()
}
pub fn remove_start_end_slash(s: &str) -> String {
let mut ss = s;
while ss.starts_with("/") {
@@ -193,7 +189,6 @@ fn parse_oss_backupd_config_item(item: &json::JsonValue, root_oss_config_object:
}
}
if encrypt_pubkey_file.is_none() && root_encrypt_pubkey_file.is_some() {
encrypt_pubkey_file = root_encrypt_pubkey_file.clone();
}
@@ -326,13 +321,14 @@ fn get_config_content(custom_oss_backupd_config: Option<&str>, verbose: bool) ->
fn get_user_home() -> XResult<String> {
match dirs::home_dir() {
None => Err(new_box_ioerror("Home dir not found!")),
Some(home_dir_o) => match home_dir_o.to_str() {
None => Err(new_box_ioerror("Home dir not found!")),
Some(home_dir_str) => Ok(home_dir_str.to_owned()),
},
Some(home_dir) => home_dir.to_str().map(|h| h.to_owned()).ok_or(new_box_ioerror("Home dir not found!")),
}
}
fn get_user_home_dir(dir: &str) -> XResult<String> {
Ok(format!("{}/{}", get_user_home()?, dir))
}
fn get_now_ymdhms() -> String {
Utc::now().format("%Y%m%d_%H%M%S").to_string()
}