add attachment symlinks option, rename binary option to attachment with export type value

This commit is contained in:
postscriptum 2025-07-02 17:10:02 +03:00
parent 9f24a133ed
commit 20c0aea8f3
6 changed files with 101 additions and 18 deletions

View file

@ -1,4 +1,7 @@
mod attachment;
use anyhow::{Result, bail};
use attachment::Attachment;
use chrono::{DateTime, Utc};
use std::{collections::HashMap, fs, path::PathBuf, str::FromStr};
@ -8,6 +11,7 @@ pub enum Source {
}
pub struct Nex {
attachment: Attachment,
filename: String,
pattern: String,
time_format: String,
@ -20,6 +24,7 @@ impl Nex {
filename: String,
time_format: String,
pattern: String,
attachment_mode: Option<String>,
user_names: &Vec<String>,
) -> Result<Self> {
use std::path::MAIN_SEPARATOR;
@ -41,9 +46,10 @@ impl Nex {
}
Ok(Self {
attachment: Attachment::init(attachment_mode)?,
filename,
time_format,
pattern,
time_format,
users,
})
}
@ -123,11 +129,7 @@ impl Nex {
);
to.push(&f);
if !to.exists() {
fs::copy(&from, &to).unwrap();
println!(
"\t\t\tcopy attachment file `{}`",
to.to_string_lossy()
)
self.attachment.sync(&from, &to).unwrap()
}
format!("{}/{f}", d.file_name().unwrap().to_string_lossy())
}
@ -171,4 +173,8 @@ impl Nex {
Ok(1)
}
pub fn is_attachments_disabled(&self) -> bool {
matches!(self.attachment, Attachment::Disabled)
}
}