update get content returns Option

This commit is contained in:
2019-12-08 22:51:34 +08:00
parent 8ac0b56bc1
commit dc1ab83d28
2 changed files with 23 additions and 12 deletions

View File

@@ -32,6 +32,13 @@ fn main() -> XResult<()> {
println!("Hello, world!");
println!("{}", SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs());
let oss_client = OSSClient::new("oss-cn-shanghai.aliyuncs.com", "", "");
let c = oss_client.get_file_content("hatterbucket", "Check.java")?;
println!("XXXXX: {:?}", c);
// println!("XXXXX: {}", );
// zip_util::zip_file("hello.txt", "aa.zip")?;
// let openpgp_client = OpenPGPTool::from_file("sample.gpg")?;
@@ -54,9 +61,11 @@ fn main() -> XResult<()> {
// TODO call it!
pub fn process_oss_files(oss_client: &OSSClient, bucket_name: &str, path: &str, meta_file_name: &str, new_file: &str, limit: usize) -> XResult<()> {
// TODO not found?
let meta_file_key = &format!("{}/{}", path, meta_file_name);
let meta_file_content = oss_client.get_file_content(bucket_name, meta_file_key)?;
let meta_file_content = match oss_client.get_file_content(bucket_name, meta_file_key)? {
None => "[]".to_string(),
Some(c) => c,
};
let (removed_file, new_meta_file_content) = process_new_backup_file(&meta_file_content, new_file, limit)?;
oss_client.put_file_content(bucket_name, meta_file_key, &new_meta_file_content)?;
if !removed_file.is_empty() {