unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Mark Walters <markwalters1009@gmail.com>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 1/3] new: Consistently treat fatal errors as fatal
Date: Sun, 22 Apr 2012 00:11:10 -0400	[thread overview]
Message-ID: <20120422041109.GA17810@mit.edu> (raw)
In-Reply-To: <87zkab4qs9.fsf@qmul.ac.uk>

Quoth Mark Walters on Apr 16 at  4:53 pm:
> 
> On Mon, 27 Feb 2012, Austin Clements <amdragon@MIT.EDU> wrote:
> > Previously, fatal errors in add_files_recursive were not treated as
> > fatal by its callers (including itself!) and add_files_recursive
> > sometimes returned errors on non-fatal conditions.  This makes
> > add_files_recursive errors consistently fatal and updates all callers
> > to treat them as fatal.
> 
> Hi I have attempted to review this but am feeling a little out of my
> depth. This patch seems fine except for one thing I am unsure about:
> 
> > ---
> >  notmuch-new.c |   13 ++++++++-----
> >  1 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/notmuch-new.c b/notmuch-new.c
> > index 4f13535..bd9786a 100644
> > --- a/notmuch-new.c
> > +++ b/notmuch-new.c
> > @@ -308,7 +308,6 @@ add_files_recursive (notmuch_database_t *notmuch,
> >      if (num_fs_entries == -1) {
> >  	fprintf (stderr, "Error opening directory %s: %s\n",
> >  		 path, strerror (errno));
> > -	ret = NOTMUCH_STATUS_FILE_ERROR;
> >  	goto DONE;
> >      }
> >  
> 
> If I understand this, then this change makes a failure to open a
> directory non-fatal. In the comment before the function it says
> 
>  *     Also, we don't immediately act on file/directory removal since we
>  *     must ensure that in the case of a rename that the new filename is
>  *     added before the old filename is removed, (so that no information
>  *     is lost from the database).
>  
> I am  worried that we could fail to find some files because of the
> file error above, and then we delete them from the database. Maybe this
> could only happen if those emails have just been moved to this
> file-error directory?

Hmm.  This won't *actively* remove files, since that only happens if
we successfully scan a directory and find a message that's in the
database but not in that directory (*not* scanning the directory won't
add anything to the remove list).  However, you are right that if a
message is moved from some other directory into a directory that we
fail to open, that message will be deleted "by omission".

I've added the error back, along with a comment explaining it.

> Best wishes
> 
> Mark
> 
> > @@ -351,8 +350,10 @@ add_files_recursive (notmuch_database_t *notmuch,
> >  
> >  	next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
> >  	status = add_files_recursive (notmuch, next, state);
> > -	if (status && ret == NOTMUCH_STATUS_SUCCESS)
> > +	if (status) {
> >  	    ret = status;
> > +	    goto DONE;
> > +	}
> >  	talloc_free (next);
> >  	next = NULL;
> >      }
> > @@ -933,6 +934,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
> >      }
> >  
> >      ret = add_files (notmuch, db_path, &add_files_state);
> > +    if (ret)
> > +	goto DONE;
> >  
> >      gettimeofday (&tv_start, NULL);
> >      for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {
> > @@ -965,6 +968,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
> >  	}
> >      }
> >  
> > +  DONE:
> >      talloc_free (add_files_state.removed_files);
> >      talloc_free (add_files_state.removed_directories);
> >      talloc_free (add_files_state.directory_mtimes);
> > @@ -1012,10 +1016,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
> >  
> >      printf ("\n");
> >  
> > -    if (ret) {
> > -	printf ("\nNote: At least one error was encountered: %s\n",
> > +    if (ret)
> > +	printf ("\nNote: A fatal error was encountered: %s\n",
> >  		notmuch_status_to_string (ret));
> > -    }
> >  
> >      notmuch_database_close (notmuch);

  reply	other threads:[~2012-04-22  4:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 15:49 [PATCH 0/3] Fix some error handling in notmuch new Austin Clements
2012-02-27 15:49 ` [PATCH 1/3] new: Consistently treat fatal errors as fatal Austin Clements
2012-04-16 15:53   ` Mark Walters
2012-04-22  4:11     ` Austin Clements [this message]
2012-02-27 15:49 ` [PATCH 2/3] new: Handle fatal errors in remove_filename and _remove_directory Austin Clements
2012-04-16 16:02   ` Mark Walters
2012-04-22  4:21     ` Austin Clements
2012-02-27 15:49 ` [PATCH 3/3] new: Print final fatal error message to stderr Austin Clements
2012-04-22  4:27 ` [PATCH v2 0/4] Fix some error handling in notmuch new Austin Clements
2012-04-22  4:27   ` [PATCH v2 1/4] new: Consistently treat fatal errors as fatal Austin Clements
2012-04-22  4:27   ` [PATCH v2 2/4] new: Handle fatal errors in remove_filename and _remove_directory Austin Clements
2012-04-22  7:34     ` Mark Walters
2012-04-22 15:36       ` Austin Clements
2012-04-22  4:27   ` [PATCH v2 3/4] new: Print final fatal error message to stderr Austin Clements
2012-04-22  4:27   ` [PATCH v2 4/4] new: Fix missing end_atomic in remove_filename on error Austin Clements
2012-04-22  7:42     ` Mark Walters
2012-04-22 15:50 ` [PATCH v3 0/4] Fix some error handling in notmuch new Austin Clements
2012-04-22 15:50   ` [PATCH v3 1/4] new: Consistently treat fatal errors as fatal Austin Clements
2012-04-25  2:28     ` David Bremner
2012-04-22 15:50   ` [PATCH v3 2/4] new: Handle fatal errors in remove_filename and _remove_directory Austin Clements
2012-04-22 15:50   ` [PATCH v3 3/4] new: Print final fatal error message to stderr Austin Clements
2012-04-22 15:50   ` [PATCH v3 4/4] new: Fix missing end_atomic in remove_filename on error Austin Clements

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=20120422041109.GA17810@mit.edu \
    --to=amdragon@mit.edu \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.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://yhetil.org/notmuch.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).