[PATCH 2/4] insert: strip trailing / in folder path
David Bremner
david at tethera.net
Fri Aug 18 17:17:25 PDT 2017
Yuri Volchkov <yuri.volchkov at gmail.com> writes:
> I have faced a problem, that messages sent by emacs could not be shown
> or found later. The "notmuch show id:<msg_id>" says "no such file or
> directory".
>
> The reason of this behavior is the following chain of events:
> 1) While sending a message, emacs calls
> notmuch insert --folder=maildir/Sent/ < test.msg
>
I think it will be less confusing if you give a more reduced description
of the bug fix here. In particular the test in your previous patch shows
that the neither offlineimap nor multiple copies of a message are needed
to trigger this bug; rather it has to do with insufficient path
canonicalization.
>
> The solution is simple, we have to strip trailing '/' from the insert
> path.
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 8f0e22a..79eb3d6 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -858,8 +858,7 @@ notmuch_database_open_verbose (const char *path,
> notmuch->status_string = NULL;
> notmuch->path = talloc_strdup (notmuch, path);
>
> - if (notmuch->path[strlen (notmuch->path) - 1] == '/')
> - notmuch->path[strlen (notmuch->path) - 1] = '\0';
> + strip_trailing(notmuch->path, '/');
These seems like a reasonable change, but I don't see the connection
with the notmuch-insert problem. Please either explain the connection in
the commit message or split the change out into a different commit with
an explanation of what it is fixing (and perhaps a seperate test, if
there's a real problem there, rather than just tidying up).
More information about the notmuch
mailing list