ref unwrap_or_else
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -179,18 +179,16 @@ fn process_oss_files(options: &Options, oss_client: &OSSClient, bucket_name: &st
|
||||
if options.verbose {
|
||||
print_message(MessageType::DEBUG, &format!("Read meta file: {}", meta_file_key));
|
||||
}
|
||||
let meta_file_content = match oss_client.get_file_content(bucket_name, meta_file_key)? {
|
||||
Some(c) => c, None => "[]".to_owned(),
|
||||
};
|
||||
let meta_file_content = oss_client.get_file_content(bucket_name, meta_file_key)?.unwrap_or_else(|| "[]".to_owned());
|
||||
if options.verbose {
|
||||
print_message(MessageType::DEBUG, &format!("Read meta file content: {}", &meta_file_content));
|
||||
}
|
||||
let (removed_file, new_meta_file_content) = process_new_backup_file(&meta_file_content, new_file, limit)?;
|
||||
let (removed_files, new_meta_file_content) = process_new_backup_file(&meta_file_content, new_file, limit)?;
|
||||
if options.verbose {
|
||||
print_message(MessageType::DEBUG, &format!("Processed meta file content: {}", &new_meta_file_content));
|
||||
}
|
||||
oss_client.put_file_content(bucket_name, meta_file_key, &new_meta_file_content)?;
|
||||
for rm_file in removed_file {
|
||||
for rm_file in removed_files {
|
||||
print_message(MessageType::INFO, &format!("Remove OSS key: {}", &rm_file));
|
||||
oss_client.delete_file(bucket_name, &rm_file)?;
|
||||
}
|
||||
@@ -205,9 +203,7 @@ fn process_new_backup_file(backup_content_json: &str, new_item: &str, limit: usi
|
||||
}
|
||||
parsed_vec.push(new_item.to_string());
|
||||
|
||||
let stringifyed_json = stringity_json_array(&parsed_vec)?;
|
||||
|
||||
Ok((removed_vec, stringifyed_json))
|
||||
Ok((removed_vec, stringity_json_array(&parsed_vec)?))
|
||||
}
|
||||
|
||||
// stringify JSON array
|
||||
|
||||
Reference in New Issue
Block a user