Re: Forcing a sync of maildir flags?

Subject: Re: Forcing a sync of maildir flags?

Date: Sun, 01 May 2022 20:23:19 -0300

To: Sean Whitton, notmuch@notmuchmail.org

Cc:

From: David Bremner


Sean Whitton <spwhitton@spwhitton.name> writes:
>
> Thanks.  Let me record in this thread what I will believe it will take a
> reproduce this in a test:
>
> 1) inbox and sent are Maildirs
>
> 1) Compose mail to a mailing list which will return copies of
>    submissions, with `Fcc: sent -unread`

Since you mention Fcc, are you using notmuch insert?

>
> 2) notmuch new, and in post-new hook, notmuch tag -unread -- folder:sent
>
> Expected result: copy of message in both inbox and sent has Seen flag
>
> Actual result: only copy of message in sent has Seen flag

I tried to simulate this in the form of a test. I'm not using notmuch
insert here, but I manage to trigger similar looking behaviour:

test_begin_subtest "duplicate file with seen flag"
test_subtest_known_broken
mkdir -p "${MAIL_DIR}"/sent/{cur,new,tmp}
notmuch config set maildir.synchronize_flags true
add_message '[subject]="seen message"'  '[filename]=fcc-file:2,S' '[dir]=sent/cur'
notmuch new
# for debugging
notmuch search subject:"seen message"
mkdir -p "${MAIL_DIR}"/inbox/{cur,new,tmp}
cp "${gen_msg_filename}" "${MAIL_DIR}"/inbox/new/copied-file:2,
notmuch new
# for debugging
notmuch search subject:"seen message"
# next line is a no-op, because it already doesn't have the unread tag
notmuch tag -unread folder:sent
count=$(notmuch search --output=files subject:"seen message" | grep -c ',S$')
# for debugging:
notmuch search --output=files subject:"seen message"
test_expect_equal "${count}" "2"

This has the output

    BROKEN duplicate file with seen flag
            --- T050-new.41.expected	2022-05-01 22:51:45.644747316 +0000
            +++ T050-new.41.output	2022-05-01 22:51:45.644747316 +0000
            @@ -1 +1 @@
            -2
            +1
    No new mail.
    thread:0000000000000011   2001-01-05 [1/1] Notmuch Test Suite; seen message (inbox)
    Processed 1 file in almost no time.
    No new mail.
    thread:0000000000000011   2001-01-05 [1/1(2)] Notmuch Test Suite; seen message (inbox)
    /home/bremner/software/upstream/notmuch/test/tmp.T050-new/mail/sent/cur/fcc-file:2,S
    /home/bremner/software/upstream/notmuch/test/tmp.T050-new/mail/inbox/new/copied-file:2,

The key point is that from notmuch's point of view the message never has
the unread tag, so there is no change for "notmuch tag" to sync with
maildir flags.

It doesn't seem to make a difference if I put the copy in inbox/new or
inbox/cur, so I don't think it is related to the previous efforts not to
prematurely move files out of new/.

As far as I can tell, notmuch-new (unlike notmuch-insert) does not call
notmuch_message_tags_to_maildir_flags, so the maildir flags on the newly
discovered copy are not updated. Perhaps it should, but that seems like
a pretty big change, so I want to proceed with caution.
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: