add fn get_safe_backup_count

This commit is contained in:
2020-04-03 08:03:19 +08:00
parent d1fda09f2e
commit 2f7ff048a7
3 changed files with 13 additions and 8 deletions

View File

@@ -93,6 +93,16 @@ impl OSSBackupdConfigItem {
None => "default_file_name".to_owned(),
}
}
pub fn get_safe_backup_count(&self) -> usize {
let mut backup_count = self.backup_count.unwrap_or(10u32) as usize;
if backup_count < 1_usize {
backup_count = 1_usize;
} else if backup_count > 10000_usize {
backup_count = 10000_usize;
}
backup_count
}
}
fn real_make_oss_key(oss_backupd_config: &OSSBackupdConfig, oss_backupd_config_item: &OSSBackupdConfigItem, suffix: &str) -> String {