maildir: do not use rename_regex when only updating flags

Concerns #463

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/500/head
Manos Pitsidianakis 2 weeks ago
parent 0c590bbc0c
commit b930cb4940
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -308,7 +308,7 @@ impl MaildirPathTrait for Path {
flag flag
} }
fn set_flags(&self, flags: Flag, config: &Configuration) -> Result<PathBuf> { fn set_flags(&self, flags: Flag, _config: &Configuration) -> Result<PathBuf> {
let filename = self let filename = self
.file_name() .file_name()
.ok_or_else(|| format!("Could not get filename of `{}`", self.display(),))? .ok_or_else(|| format!("Could not get filename of `{}`", self.display(),))?
@ -324,11 +324,7 @@ impl MaildirPathTrait for Path {
); );
(filename.len(), true) (filename.len(), true)
}; };
let mut new_name: String = if let Some(ref rename_regex) = config.rename_regex { let mut new_name: String = filename[..idx].to_string();
rename_regex.replace_all(&filename[..idx], "").to_string()
} else {
filename[..idx].to_string()
};
if append_2 { if append_2 {
new_name.push_str(":2,"); new_name.push_str(":2,");
} }

@ -147,7 +147,7 @@ fn test_maildir_set_flags_regexp() {
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,S"), Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,S"),
&[FlagOp::Set(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)] &[FlagOp::Set(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)]
), ),
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,FRS").to_path_buf()), Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS").to_path_buf()),
"Setting the same flags should not change the path" "Setting the same flags should not change the path"
); );
assert_eq!( assert_eq!(
@ -156,7 +156,7 @@ fn test_maildir_set_flags_regexp() {
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"), Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"),
&[FlagOp::UnSet(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)] &[FlagOp::UnSet(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)]
), ),
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,").to_path_buf()), Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,").to_path_buf()),
"UnSetting all the set flags should change the path" "UnSetting all the set flags should change the path"
); );
assert_eq!( assert_eq!(
@ -165,7 +165,7 @@ fn test_maildir_set_flags_regexp() {
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"), Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"),
&[FlagOp::Set(Flag::FLAGGED | Flag::TRASHED)] &[FlagOp::Set(Flag::FLAGGED | Flag::TRASHED)]
), ),
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,FRST").to_path_buf()), Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRST").to_path_buf()),
"Setting new flags should change the path to include them" "Setting new flags should change the path to include them"
); );
} }

Loading…
Cancel
Save