From 608301dc3d7c8c81f5f650cf0d753ac2b5a85095 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 7 Jul 2024 19:04:27 +0300 Subject: [PATCH] mail/view/envelope: Expand save-to paths asap Paths entered via command were not expanded as soon as the text was converted into a PathBuf, but when the save-to-file function was called. This resulted in tilde expansion not happening until then, which because of buggy behavior the previous commit fixed (expanding the tilde in the middle of a path and pushing it to an existing path overwrites its value, because expanding the tilde usually results in an absolute path), resulted in the correct behavior. The invalid path was still visible on the success message. Instead, expand the path right away and then do modifications like setting filename etc. Fixes: #431 Signed-off-by: Manos Pitsidianakis --- meli/src/mail/view/envelope.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meli/src/mail/view/envelope.rs b/meli/src/mail/view/envelope.rs index 843bab69..e63c998e 100644 --- a/meli/src/mail/view/envelope.rs +++ b/meli/src/mail/view/envelope.rs @@ -21,7 +21,7 @@ use std::process::{Command, Stdio}; -use melib::utils::xdg::query_default_app; +use melib::utils::{shellexpand::ShellExpandTrait, xdg::query_default_app}; use super::*; use crate::ThreadEvent; @@ -1492,7 +1492,7 @@ impl Component for EnvelopeView { } UIEvent::Action(View(ViewAction::ExportMail(ref path))) => { // Save entire message as eml - let mut path = std::path::Path::new(path).to_path_buf(); + let mut path = std::path::Path::new(path).to_path_buf().expand(); if path.is_dir() { path.push(format!("{}.eml", self.mail.message_id_raw())); @@ -1526,7 +1526,7 @@ impl Component for EnvelopeView { return true; } UIEvent::Action(View(ViewAction::SaveAttachment(a_i, ref path))) => { - let mut path = std::path::Path::new(path).to_path_buf(); + let mut path = std::path::Path::new(path).to_path_buf().expand(); if let Some(u) = self.open_attachment(a_i, context) { if path.is_dir() {