Refactor: PAtomicInfo class

This commit is contained in:
andy.boot
2023-01-14 19:13:23 +00:00
parent 9f0f366187
commit 6c130adb6c
3 changed files with 30 additions and 46 deletions
+11
View File
@@ -1,5 +1,6 @@
use std::{
io::Write,
path::Path,
sync::{
atomic::{AtomicBool, AtomicU64, AtomicU8, AtomicUsize, Ordering},
Arc, RwLock,
@@ -56,6 +57,16 @@ pub struct PAtomicInfo {
pub no_permissions: AtomicBool,
}
impl PAtomicInfo {
pub fn clear_state(&self, dir: &Path) {
self.state.store(Operation::INDEXING, ORDERING);
let dir_name = dir.to_string_lossy().to_string();
self.current_path.set(dir_name);
self.total_file_size.store(0, ORDERING);
self.file_number.store(0, ORDERING);
}
}
/* -------------------------------------------------------------------------- */
fn format_indicator_str(data: &PAtomicInfo, progress_char_i: usize, status: &str) -> String {
format!(