Need fallback behaviour when dirs::download_dir returns None (#118)

This commit is contained in:
Ulyssa
2023-07-07 20:35:01 -07:00
parent 3da9835a17
commit 6e8e12b579
4 changed files with 10 additions and 9 deletions

View File

@@ -186,9 +186,10 @@ impl ChatState {
if let MessageEvent::Original(ev) = &msg.event {
let media = client.media();
let mut filename = match filename {
Some(f) => PathBuf::from(f),
None => settings.dirs.downloads.clone(),
let mut filename = match (filename, &settings.dirs.downloads) {
(Some(f), _) => PathBuf::from(f),
(None, Some(downloads)) => downloads.clone(),
(None, None) => return Err(IambError::NoDownloadDir.into()),
};
let (source, msg_filename) = match &ev.content.msgtype {