ui: file_name() does not return full file_name

move_to_cur doesn't retain the full envelope name when moving
embed
Manos Pitsidianakis 2019-04-26 11:54:31 +03:00
parent 1e44089d84
commit 3790f68e3f
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 6 additions and 3 deletions

View File

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