diff --git a/src/nex.rs b/src/nex.rs index 1dbb36b..a74d0b9 100644 --- a/src/nex.rs +++ b/src/nex.rs @@ -85,22 +85,22 @@ impl Nex { let root = PathBuf::from(self.users.get(name).unwrap()); let mut p = PathBuf::from(&root); if let Some(ref mut i) = index { - i.push(root); + i.push(root) } p.push(published.format("%Y").to_string()); if let Some(ref mut i) = index { - i.push(p.clone()); + i.push(p.clone()) } p.push(published.format("%m").to_string()); if let Some(ref mut i) = index { - i.push(p.clone()); + i.push(p.clone()) } p.push(published.format("%d").to_string()); if let Some(ref mut i) = index { - i.push(p.clone()); + i.push(p.clone()) } fs::create_dir_all(&p)?; @@ -123,11 +123,11 @@ impl Nex { // if this meta file exists and has timestamp changed, also cleanup attachment files to update let mut s = PathBuf::from(&d); s.push(".state"); - if !s.exists() || updated.is_some_and(|u| u.to_string() != fs::read_to_string(&s).unwrap()) - { + let state = updated.unwrap_or(published).to_string(); + if !fs::read_to_string(&s).is_ok_and(|this| this == state) { fs::remove_dir_all(&d)?; fs::create_dir_all(&d)?; - fs::write(&s, updated.unwrap_or(published).to_string())? + fs::write(&s, state)? } else { if let Some(ref mut i) = index { if let Some(ref a) = attachments { @@ -138,7 +138,7 @@ impl Nex { } } } - i.extend([d, f, p, s]); + i.extend([d, f, p, s]) } return Ok(Sync { change: Change::Ignored, @@ -176,9 +176,7 @@ impl Nex { d.file_name().unwrap().to_string_lossy(), to.file_name().unwrap().to_string_lossy() ); - if !to.exists() { - self.attachment.sync(&from, &to).unwrap() - } + self.attachment.sync(&from, &to).unwrap(); if let Some(ref mut i) = index { i.push(to); }