chore: use FILES_TO_IGNORE to exclude files in cleanup_target
This commit is contained in:
parent
4b9e2ab631
commit
c13b2fe3ad
@ -1,5 +1,5 @@
|
|||||||
use crate::tools;
|
use crate::tools;
|
||||||
use crate::{FILES_TO_CONVERT, FILES_TO_COPY};
|
use crate::{FILES_TO_CONVERT, FILES_TO_COPY, FILES_TO_IGNORE};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@ -87,9 +87,16 @@ impl DirectoryProcessor {
|
|||||||
format!("Error getting relative path for {}: {}", path.display(), e)
|
format!("Error getting relative path for {}: {}", path.display(), e)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
// Skip files that should be ignored
|
||||||
|
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
|
||||||
|
if FILES_TO_IGNORE.iter().any(|&ignore| file_name.ends_with(ignore)) {
|
||||||
|
is_empty = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if this file should exist based on source files
|
// Check if this file should exist based on source files
|
||||||
let should_exist = if let Some(ext) = rel_path.extension().and_then(|e| e.to_str())
|
let should_exist = if let Some(ext) = rel_path.extension().and_then(|e| e.to_str()) {
|
||||||
{
|
|
||||||
if ext == "pdf" {
|
if ext == "pdf" {
|
||||||
// For PDF files, check if any corresponding source file exists
|
// For PDF files, check if any corresponding source file exists
|
||||||
FILES_TO_CONVERT
|
FILES_TO_CONVERT
|
||||||
|
@ -10,6 +10,7 @@ pub const FILES_TO_COPY: [&str; 10] = [
|
|||||||
"jpg", "jpeg", "png", "gif", "bmp", "tiff", "webp", "avif", "txt", "md",
|
"jpg", "jpeg", "png", "gif", "bmp", "tiff", "webp", "avif", "txt", "md",
|
||||||
];
|
];
|
||||||
pub const FILES_TO_CONVERT: [&str; 3] = ["odt", "doc", "docx"];
|
pub const FILES_TO_CONVERT: [&str; 3] = ["odt", "doc", "docx"];
|
||||||
|
pub const FILES_TO_IGNORE: [&str; 1] = ["DS_Store"];
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(
|
#[command(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user