warn on using reserved chars instead of trim

This commit is contained in:
postscriptum 2025-07-02 14:40:09 +03:00
parent 1df12cee92
commit 9f24a133ed

View file

@ -22,10 +22,14 @@ impl Nex {
pattern: String, pattern: String,
user_names: &Vec<String>, user_names: &Vec<String>,
) -> Result<Self> { ) -> Result<Self> {
use std::path::MAIN_SEPARATOR;
if filename.contains(MAIN_SEPARATOR) {
bail!("Filename pattern should not contain `{MAIN_SEPARATOR}` characters!")
}
// init data export location // init data export location
let target = PathBuf::from_str(&target_dir)?.canonicalize()?; let target = PathBuf::from_str(&target_dir)?.canonicalize()?;
if !target.is_dir() { if !target.is_dir() {
bail!("Target location is not directory!"); bail!("Target location is not directory!")
} }
// init locations for each user // init locations for each user
let mut users = HashMap::with_capacity(user_names.len()); let mut users = HashMap::with_capacity(user_names.len());
@ -156,11 +160,7 @@ impl Nex {
); );
// save post file // save post file
p.push( p.push(published.format(&self.filename).to_string());
published
.format(self.filename.trim_matches(std::path::MAIN_SEPARATOR))
.to_string(),
);
let f = p.to_string_lossy(); let f = p.to_string_lossy();
if fs::exists(&p)? { if fs::exists(&p)? {
println!("\t\t\tpost file `{f}` update with new content.") println!("\t\t\tpost file `{f}` update with new content.")