unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 50450@debbugs.gnu.org
Subject: bug#50450: 28.0.50; nnmaildir cannot find article file
Date: Wed, 15 Sep 2021 09:03:16 +0000	[thread overview]
Message-ID: <871r5q43e3.fsf@posteo.net> (raw)
In-Reply-To: <87ilzccsxk.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 07 Sep 2021 17:21:43 +0200")

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>>From time to time I get error messages like
>>
>> nnmaildir--article-set-flags: Couldn’t find article file
>> /home/philip/Mail/Pers/Sent/cur/1631002186.M670797P704685Q0.icterid:2,S
>>
>> when trying to send a message.
>
> I don't use nnmaildir myself (and I'm not familiar with how maildir
> works, really).  Can you propose a patch to fix this yourself?  :-)

I found out that the issue is not the UID, but the flags. Specifically,
when I open a message via Gnus, leave it open for a while, perhaps check
the message on my phone or some other device, and then return to Gnus,
it might have happened that the flags (included in the file-name) were
updated by mbsync.

This patch attempts to find a similar file, and renames that file
instead of the one Gnus remembered. It seems to be working for now, but
I'd wait a bit until I had more time to test it before applying it:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-updates-flags-when-setting-flags.patch --]
[-- Type: text/x-diff, Size: 1401 bytes --]

From facb1848952d5c844d76844e35da708fda8307c7 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Wed, 15 Sep 2021 10:58:50 +0200
Subject: [PATCH] Handle updates flags when setting flags

* nnmaildir.el (nnmaildir--article-set-flags): Handle updated flags
  more gracefully
---
 lisp/gnus/nnmaildir.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index 171f0813b3..690761a2d6 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -194,7 +194,15 @@ nnmaildir--article-set-flags
 	 (article-file (concat curdir prefix suffix))
 	 (new-name (concat curdir prefix new-suffix)))
     (unless (file-exists-p article-file)
-      (error "Couldn't find article file %s" article-file))
+      (let ((possible (file-expand-wildcards (concat curdir prefix "*"))))
+	(cond ((length= possible 1)
+	       (unless (string-match-p "\\`\\(.+\\):2,.*?\\'" (car possible))
+		 (error "Couldn't find updated article file %s" article-file))
+	       (setq article-file (car possible)))
+	      ((length> possible 1)
+	       (error "Couldn't determine exact article file %s" article-file))
+	      ((null possible)
+	       (error "Couldn't find article file %s" article-file)))))
     (rename-file article-file new-name 'replace)
     (setf (nnmaildir--art-suffix article) new-suffix)))
 
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 147 bytes --]


One possible issue is that nnmaildir--article-set-flags overwrites
previous flags that might have been updated elsewhere.

-- 
	Philip Kaludercic

  parent reply	other threads:[~2021-09-15  9:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  8:22 bug#50450: 28.0.50; nnmaildir cannot find article file Philip Kaludercic
2021-09-07 15:21 ` Lars Ingebrigtsen
2021-09-07 16:25   ` Philip Kaludercic
2021-09-08  7:46     ` Lars Ingebrigtsen
2021-09-15  9:03   ` Philip Kaludercic [this message]
2021-09-16 12:11     ` Lars Ingebrigtsen
2021-09-23 18:56       ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r5q43e3.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=50450@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).