mirror of https://github.com/djcb/mu.git
store: better handling moving messages
sort results (for testing) with the ChangeName flag, also apply to dup messages.
This commit is contained in:
parent
5d37c18d7d
commit
b0dca49dc0
|
@ -548,7 +548,7 @@ Store::move_message(Store::Id id,
|
||||||
if (none_of(opts & Store::MoveOptions::DupFlags) || message_id.empty() || !new_flags)
|
if (none_of(opts & Store::MoveOptions::DupFlags) || message_id.empty() || !new_flags)
|
||||||
return Ok(std::move(id_paths));
|
return Ok(std::move(id_paths));
|
||||||
|
|
||||||
/* handle the dupflags case; i.e. apply (a subset of) the flags to
|
/* handle the dup-flags case; i.e. apply (a subset of) the flags to
|
||||||
* all messages with the same message-id as well */
|
* all messages with the same message-id as well */
|
||||||
auto dups{priv_->find_duplicates_unlocked(*this, message_id)};
|
auto dups{priv_->find_duplicates_unlocked(*this, message_id)};
|
||||||
for (auto&& dupid: dups) {
|
for (auto&& dupid: dups) {
|
||||||
|
@ -562,17 +562,20 @@ Store::move_message(Store::Id id,
|
||||||
|
|
||||||
/* For now, don't change Draft/Flagged/Trashed */
|
/* For now, don't change Draft/Flagged/Trashed */
|
||||||
const auto dup_flags{filter_dup_flags(dup_msg->flags(), *new_flags)};
|
const auto dup_flags{filter_dup_flags(dup_msg->flags(), *new_flags)};
|
||||||
/* use the updated new_flags and default MoveOptions (so we don't recurse, nor do we
|
/* use the updated new_flags and MoveOptions without DupFlags (so we don't
|
||||||
* change the base-name of moved messages) */
|
* recurse) */
|
||||||
|
opts = opts & ~MoveOptions::DupFlags;
|
||||||
if (auto dup_res = priv_->move_message_unlocked(
|
if (auto dup_res = priv_->move_message_unlocked(
|
||||||
std::move(*dup_msg), Nothing,
|
std::move(*dup_msg), Nothing, dup_flags, opts); !dup_res)
|
||||||
dup_flags,
|
|
||||||
Store::MoveOptions::None); !dup_res)
|
|
||||||
mu_warning("failed to move dup: {}", dup_res.error().what());
|
mu_warning("failed to move dup: {}", dup_res.error().what());
|
||||||
else
|
else
|
||||||
id_paths.emplace_back(dupid, dup_res->first);
|
id_paths.emplace_back(dupid, dup_res->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort the dup paths by name;
|
||||||
|
std::sort(id_paths.begin() + 1, id_paths.end(),
|
||||||
|
[](const auto& idp1, const auto& idp2) { return idp1.second < idp2.second; });
|
||||||
|
|
||||||
return Ok(std::move(id_paths));
|
return Ok(std::move(id_paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,9 @@ public:
|
||||||
* @return Result, either an IdPathVec with ids and paths for the moved message(s) or some
|
* @return Result, either an IdPathVec with ids and paths for the moved message(s) or some
|
||||||
* error. Note that in case of success at least one message is returned, and only with
|
* error. Note that in case of success at least one message is returned, and only with
|
||||||
* MoveOptions::DupFlags can it be more than one.
|
* MoveOptions::DupFlags can it be more than one.
|
||||||
|
*
|
||||||
|
* The first element of the IdPathVec, is the main message that got move; any subsequent
|
||||||
|
* (if any) are the duplicate paths, sorted by path-name.
|
||||||
*/
|
*/
|
||||||
Result<IdPathVec> move_message(Store::Id id,
|
Result<IdPathVec> move_message(Store::Id id,
|
||||||
Option<const std::string&> target_mdir = Nothing,
|
Option<const std::string&> target_mdir = Nothing,
|
||||||
|
|
Loading…
Reference in New Issue