apt-mirror-check 1.0.0

Check errors for apt mirror
Documentation
use std::path::Path;

pub struct BadAction {
    delete: bool,
}

impl BadAction {
    pub fn new(delete: bool) -> Self {
        Self { delete }
    }
    
    /// print the error message (may delete the file first)
    pub fn on_bad_file(&self, path: &Path) {
        if self.delete {
            match std::fs::remove_file(path) {
                Ok(_) => {
                    println!("[DELETED] {}", path.display());
                }
                Err(_) => {
                    println!("[BAD] {}", path.display());
                    log::error!(path:?; "Failed to delete file");
                }
            }
        } else {
            println!("[BAD] {}", path.display())
        }
    }
}