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