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

@ -16,17 +16,18 @@ fn main() -> Result<()> {
c.format_filename,
c.format_updated,
c.format_content,
c.attachment,
&c.user,
)?;
let s = Snac::init(c.source, c.user)?;
println!("export begin...");
let (mut u, mut t) = sync(&s, &n, c.binary)?;
let (mut u, mut t) = sync(&s, &n)?;
match c.rotate {
Some(r) => loop {
println!("queue completed (updated: {u} / total: {t}), await {r} seconds to rotate...");
std::thread::sleep(std::time::Duration::from_secs(r));
(u, t) = sync(&s, &n, c.binary)?;
(u, t) = sync(&s, &n)?;
},
None => println!("export completed (updated: {u} / total: {t})."),
}
@ -34,7 +35,7 @@ fn main() -> Result<()> {
Ok(())
}
fn sync(snac: &Snac, nex: &Nex, is_binary: bool) -> Result<(usize, usize)> {
fn sync(snac: &Snac, nex: &Nex) -> Result<(usize, usize)> {
let mut t = 0; // total
let mut u = 0; // updated
for user in &snac.users {
@ -55,13 +56,13 @@ fn sync(snac: &Snac, nex: &Nex, is_binary: bool) -> Result<(usize, usize)> {
attachments.push((
attachment.name,
attachment.media_type,
if is_binary {
if nex.is_attachments_disabled() {
Source::Url(attachment.url)
} else {
Source::File(
user.file(attachment.url.split('/').next_back().unwrap())
.unwrap(),
)
} else {
Source::Url(attachment.url)
},
))
}