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