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 <manos@pitsidianak.is>
pull/432/head
Manos Pitsidianakis 2 months ago
parent 39e903b1d3
commit 608301dc3d
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -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() {

Loading…
Cancel
Save