mu-maildir: fix message_file_parts / empty flags

Remove the suffix part even with no flags.

Fixes: issue #2268
This commit is contained in:
Dirk-Jan C. Binnema 2022-05-31 23:41:50 +03:00
parent 022ae9c2e3
commit 26d64ec78f
2 changed files with 9 additions and 11 deletions

View File

@ -247,8 +247,6 @@ Mu::maildir_clear_links(const std::string& path)
return Ok(); return Ok();
} }
Result<std::string> Result<std::string>
Mu::maildir_from_path(const std::string& path, const std::string& root) Mu::maildir_from_path(const std::string& path, const std::string& root)
{ {
@ -303,7 +301,7 @@ message_file_parts(const std::string& file)
/* no suffix at all? */ /* no suffix at all? */
if (pos == std::string::npos || if (pos == std::string::npos ||
pos >= file.length() - 3 || pos > file.length() - 3 ||
file[pos + 1] != '2' || file[pos + 1] != '2' ||
file[pos + 2] != ',') file[pos + 2] != ',')
return FileParts{ file, ':', {}}; return FileParts{ file, ':', {}};
@ -559,11 +557,11 @@ check_determine_target_params (const std::string& old_path,
Mu::Result<std::string> Mu::Result<std::string>
Mu::maildir_determine_target(const std::string& old_path, Mu::maildir_determine_target(const std::string& old_path,
const std::string& root_maildir_path, const std::string& root_maildir_path,
const std::string& target_maildir, const std::string& target_maildir,
Flags newflags, Flags newflags,
bool new_name) bool new_name)
{ {
/* sanity checks */ /* sanity checks */
if (const auto checked{check_determine_target_params( if (const auto checked{check_determine_target_params(
@ -579,8 +577,8 @@ Mu::maildir_determine_target(const std::string& old_path,
return Err(src.error()); return Err(src.error());
const auto& [src_mdir, src_file, is_new] = *src; const auto& [src_mdir, src_file, is_new] = *src;
/* if target_mdir is empty, we use the src_dir does not change /* if target_mdir is empty, the src_dir does not change (though cur/
* (though cur/ maybe become new or vice-versa) */ * maybe become new or vice-versa) */
const auto dst_mdir{target_maildir.empty() ? src_mdir : const auto dst_mdir{target_maildir.empty() ? src_mdir :
root_maildir_path + target_maildir}; root_maildir_path + target_maildir};

View File

@ -94,7 +94,7 @@ Result<Flags> maildir_flags_from_path(const std::string& pathname);
* @return the maildir or an Error * @return the maildir or an Error
*/ */
Result<std::string> maildir_from_path(const std::string& path, Result<std::string> maildir_from_path(const std::string& path,
const std::string& root); const std::string& root);
/** /**
* Move a message file to another maildir. If the target file already exists, it * Move a message file to another maildir. If the target file already exists, it