Skip to content

Commit 4b8d4dd

Browse files
author
chenjunliang
committed
fmt
1 parent 33d4e97 commit 4b8d4dd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/tasks.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ fn mysql_audit_log_rotate(sched: &mut JobScheduler, path: String, max_size: u32,
2828
if file_size >= file_max_size {
2929
println!("The file size reaches the split standard:{:?}M", file_size);
3030
let file_path = Path::new(path.as_str());
31-
let origin_file_name = file_path.file_name().unwrap().to_str().unwrap().to_string();
32-
let sv: Vec<&str> = origin_file_name
33-
.split(".")
34-
.collect();
31+
let origin_file_name =
32+
file_path.file_name().unwrap().to_str().unwrap().to_string();
33+
let sv: Vec<&str> = origin_file_name.split(".").collect();
3534
let origin_name = sv[0];
3635
let origin_file_type = sv[1];
3736
println!("origin_name:{}", origin_name);
@@ -41,8 +40,10 @@ fn mysql_audit_log_rotate(sched: &mut JobScheduler, path: String, max_size: u32,
4140

4241
let local: DateTime<Local> = Local::now();
4342
let time_str = local.format("%Y%m%d%H%M%S").to_string();
44-
let new_file_name = origin_name.to_owned() + "-" + time_str.as_str() + "." + origin_file_type;
45-
let new_file_path = parent_path.to_str().unwrap().to_owned() + "/" + new_file_name.as_str();
43+
let new_file_name =
44+
origin_name.to_owned() + "-" + time_str.as_str() + "." + origin_file_type;
45+
let new_file_path =
46+
parent_path.to_str().unwrap().to_owned() + "/" + new_file_name.as_str();
4647
fs::copy(file_path, new_file_path.as_str()).unwrap();
4748
println!("Log file copied to:{}", new_file_path);
4849

@@ -59,8 +60,10 @@ fn mysql_audit_log_rotate(sched: &mut JobScheduler, path: String, max_size: u32,
5960
println!("The number of files exceeds the limit,start cleaning...");
6061
for i in 0..(files.len() - max_file as usize) {
6162
let item_file_name = files.get(i).unwrap();
62-
let item_path = parent_path.to_str().unwrap().to_owned() + "/" + item_file_name;
63-
fs::remove_file(item_path.as_str()).expect("Failed to clean up redundant files");
63+
let item_path =
64+
parent_path.to_str().unwrap().to_owned() + "/" + item_file_name;
65+
fs::remove_file(item_path.as_str())
66+
.expect("Failed to clean up redundant files");
6467
println!("Delete file {}", item_path);
6568
}
6669
}

0 commit comments

Comments
 (0)