Notify when attachment download succeeds, fix deadlock in attachment store
This commit is contained in:
@@ -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(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user