Private
Public Access
1
0

Notify when attachment download succeeds, fix deadlock in attachment store

This commit is contained in:
2025-06-06 20:02:09 -07:00
parent 1d3b2f25ba
commit 4ddc0dca39
11 changed files with 126 additions and 35 deletions

View File

@@ -19,16 +19,28 @@ pub struct Attachment {
}
impl Attachment {
pub fn get_path(&self, preview: bool) -> PathBuf {
self.base_path
.with_extension(if preview { "preview" } else { "full" })
pub fn get_path(&self) -> PathBuf {
self.get_path_for_preview_scratch(false, false)
}
pub fn get_path_for_preview(&self, preview: bool) -> PathBuf {
self.get_path_for_preview_scratch(preview, false)
}
pub fn get_path_for_preview_scratch(&self, preview: bool, scratch: bool) -> PathBuf {
let extension = if preview { "preview" } else { "full" };
if scratch {
self.base_path.with_extension(format!("{}.download", extension))
} else {
self.base_path.with_extension(extension)
}
}
pub fn is_downloaded(&self, preview: bool) -> bool {
std::fs::exists(&self.get_path(preview)).expect(
std::fs::exists(&self.get_path_for_preview(preview)).expect(
format!(
"Wasn't able to check for the existence of an attachment file path at {}",
&self.get_path(preview).display()
&self.get_path_for_preview(preview).display()
)
.as_str(),
)