From 3790f68e3fd8c5680e10485a8ae23b4216bcc169 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 26 Apr 2019 11:54:31 +0300 Subject: [PATCH] ui: file_name() does not return full file_name move_to_cur doesn't retain the full envelope name when moving --- melib/src/mailbox/backends/maildir/backend.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/melib/src/mailbox/backends/maildir/backend.rs b/melib/src/mailbox/backends/maildir/backend.rs index b007d6609..feba91ff1 100644 --- a/melib/src/mailbox/backends/maildir/backend.rs +++ b/melib/src/mailbox/backends/maildir/backend.rs @@ -127,13 +127,16 @@ pub(super) fn get_file_hash(file: &Path) -> EnvelopeHash { fn move_to_cur(p: PathBuf) -> PathBuf { let mut new = p.clone(); - let file_name = p.file_name().unwrap(); + let file_name = p.to_string_lossy(); + let slash_pos = file_name.bytes().rposition(|c| c == b'/').unwrap() + 1; new.pop(); new.pop(); new.push("cur"); - new.push(file_name); - new.set_extension(":2,"); + new.push(&file_name[slash_pos..]); + if !file_name.ends_with(":2,") { + new.set_extension(":2,"); + } if cfg!(debug_assertions) { eprint!("{}:{}_{}: ", file!(), line!(), column!()); eprintln!("moved to cur: {}", new.display());