use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CopyReason {
Missing,
MetadataChanged,
ContentChanged,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PlanOperation {
CreateDirectory {
relative_path: PathBuf,
},
CopyFile {
relative_path: PathBuf,
bytes: u64,
reason: CopyReason,
},
SetMetadata {
relative_path: PathBuf,
},
DeleteFile {
relative_path: PathBuf,
},
DeleteDirectory {
relative_path: PathBuf,
},
DeleteSymlink {
relative_path: PathBuf,
},
}
#[derive(Debug, Clone, Default)]
pub struct SyncPlan {
pub operations: Vec<PlanOperation>,
pub bytes_to_copy: u64,
pub blake3_compared_files: usize,
}
impl SyncPlan {
pub fn push(&mut self, operation: PlanOperation) {
if let PlanOperation::CopyFile { bytes, .. } = operation {
self.bytes_to_copy = self.bytes_to_copy.saturating_add(bytes);
}
self.operations.push(operation);
}
pub fn record_blake3_comparison(&mut self) {
self.blake3_compared_files = self.blake3_compared_files.saturating_add(1);
}
}