update min/max
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
cmp::{min, max, },
|
||||
fs,
|
||||
path::Path,
|
||||
};
|
||||
@@ -98,13 +99,10 @@ impl OSSBackupdConfigItem {
|
||||
}
|
||||
|
||||
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
|
||||
min(
|
||||
max(self.backup_count.unwrap_or(10u32) as usize, 1_usize),
|
||||
1000_usize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +131,7 @@ pub fn remove_start_end_slash(s: &str) -> String {
|
||||
while ss.ends_with("/") {
|
||||
ss = &ss[0..(ss.len() - 1)];
|
||||
}
|
||||
ss.to_string()
|
||||
ss.to_owned()
|
||||
}
|
||||
|
||||
pub fn parse_config(config_json: &json::JsonValue) -> OSSBackupdConfig {
|
||||
|
||||
Reference in New Issue
Block a user