Skip to content

Commit b930cb4

Browse files
committed
maildir: do not use rename_regex when only updating flags
Concerns #463 Signed-off-by: Manos Pitsidianakis <[email protected]>
1 parent 0c590bb commit b930cb4

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

melib/src/maildir/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl MaildirPathTrait for Path {
308308
flag
309309
}
310310

311-
fn set_flags(&self, flags: Flag, config: &Configuration) -> Result<PathBuf> {
311+
fn set_flags(&self, flags: Flag, _config: &Configuration) -> Result<PathBuf> {
312312
let filename = self
313313
.file_name()
314314
.ok_or_else(|| format!("Could not get filename of `{}`", self.display(),))?
@@ -324,11 +324,7 @@ impl MaildirPathTrait for Path {
324324
);
325325
(filename.len(), true)
326326
};
327-
let mut new_name: String = if let Some(ref rename_regex) = config.rename_regex {
328-
rename_regex.replace_all(&filename[..idx], "").to_string()
329-
} else {
330-
filename[..idx].to_string()
331-
};
327+
let mut new_name: String = filename[..idx].to_string();
332328
if append_2 {
333329
new_name.push_str(":2,");
334330
}

melib/src/maildir/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn test_maildir_set_flags_regexp() {
147147
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,S"),
148148
&[FlagOp::Set(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)]
149149
),
150-
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,FRS").to_path_buf()),
150+
Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS").to_path_buf()),
151151
"Setting the same flags should not change the path"
152152
);
153153
assert_eq!(
@@ -156,7 +156,7 @@ fn test_maildir_set_flags_regexp() {
156156
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"),
157157
&[FlagOp::UnSet(Flag::FLAGGED | Flag::SEEN | Flag::REPLIED)]
158158
),
159-
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,").to_path_buf()),
159+
Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,").to_path_buf()),
160160
"UnSetting all the set flags should change the path"
161161
);
162162
assert_eq!(
@@ -165,7 +165,7 @@ fn test_maildir_set_flags_regexp() {
165165
Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRS"),
166166
&[FlagOp::Set(Flag::FLAGGED | Flag::TRASHED)]
167167
),
168-
Ok(Path::new("/path/to/new/1423819205.29514_1.foo:2,FRST").to_path_buf()),
168+
Ok(Path::new("/path/to/new/1423819205.29514_1.foo,U=123:2,FRST").to_path_buf()),
169169
"Setting new flags should change the path to include them"
170170
);
171171
}

0 commit comments

Comments
 (0)