Re: [PATCH 2/2] cli: reset db directory mtime upon directory removal

Subject: Re: [PATCH 2/2] cli: reset db directory mtime upon directory removal

Date: Sun, 06 Sep 2015 13:00:42 +0300

To: Jani Nikula, Mark Walters, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


On Sat, Sep 05 2015, Jani Nikula <jani@nikula.org> wrote:

> The library does not have a function to remove a directory document
> for a path. Usually this doesn't matter except for a slight waste of
> space. However, if the same directory gets added to the filesystem
> again, the old directory document is found with the old mtime. Reset
> the directory mtime on removal to avoid problems.
>
> The corner case that can hit this problem is renaming directories back
> and forth. Renaming does not change the mtime of the directory in the
> filesystem, and thus the old db directory document mtime may match the
> fs mtime of the directory.
>
> The long term fix might be to add a library function to remove a
> directory document, however this is a much simpler and faster fix for
> the time being.
> ---

LGTM.

Tomi


>  notmuch-new.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 514e06a4d1f3..33645349cd5f 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -878,6 +878,15 @@ _remove_directory (void *ctx,
>  	    goto DONE;
>      }
>  
> +    /*
> +     * XXX: The library does not have a function to remove a directory
> +     * document for a path. Usually this doesn't matter except for a
> +     * slight waste of space. However, if the directory gets added to
> +     * the filesystem again, the old directory document is found with
> +     * the old mtime. Reset the directory mtime to avoid problems.
> +     */
> +    notmuch_directory_set_mtime (directory, 0);
> +
>    DONE:
>      notmuch_directory_destroy (directory);
>      return status;
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

Thread: