mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-04-01 05:35:27 +00:00
add attachment symlinks option, rename binary option to attachment with export type value
This commit is contained in:
parent
9f24a133ed
commit
20c0aea8f3
6 changed files with 101 additions and 18 deletions
18
src/nex.rs
18
src/nex.rs
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue