From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3932D431FBC for ; Tue, 16 Feb 2010 01:35:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.241 X-Spam-Level: X-Spam-Status: No, score=-2.241 tagged_above=-999 required=5 tests=[AWL=0.358, BAYES_00=-2.599] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8OGYnQmTiO3C for ; Tue, 16 Feb 2010 01:35:33 -0800 (PST) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id F07FB431FAE for ; Tue, 16 Feb 2010 01:35:32 -0800 (PST) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id E260119F3337; Tue, 16 Feb 2010 10:35:31 +0100 (CET) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id cCmLeC2TiwUL; Tue, 16 Feb 2010 10:35:27 +0100 (CET) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id B51A719F3312; Tue, 16 Feb 2010 10:35:27 +0100 (CET) Received: from steelpick.localdomain (k335-30.felk.cvut.cz [147.32.86.30]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 91236FA003; Tue, 16 Feb 2010 10:35:27 +0100 (CET) Received: from wsh by steelpick.localdomain with local (Exim 4.71) (envelope-from ) id 1NhJq3-0000zD-F2; Tue, 16 Feb 2010 10:35:27 +0100 From: Michal Sojka To: Stewart Smith , Tim Stoakes , notmuch@notmuchmail.org In-Reply-To: <20100216022128.GH22402@flamingspork.com> References: <87d43b2oif.fsf@yoom.home.cworth.org> <9bfdedddeab9c58cd45d8d448323d0fc@localhost> <87skc23327.fsf@yoom.home.cworth.org> <4b0eef22.JwxdgTGElffx149F%michiel@michielbuddingh.net> <87ws1bjpmm.fsf@yoom.home.cworth.org> <878wdfkhcl.fsf@aegir.org.uk> <20100210031339.GH16686@mail.rocksoft.com> <20100215081331.GD22402@flamingspork.com> <20100216015856.GG22402@flamingspork.com> <20100216021250.GB21780@lapse.rw.madduck.net> <20100216022128.GH22402@flamingspork.com> Date: Tue, 16 Feb 2010 10:35:27 +0100 Message-ID: <87vddxikv4.fsf@steelpick.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [PATCH] notmuch: Respect maildir message flags X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 09:35:34 -0000 On Tue, 16 Feb 2010 13:21:28 +1100, Stewart Smith wrote: > What about this patch (just with those few things fixed)? > > diff --git a/notmuch-new.c b/notmuch-new.c > index f25c71f..8303047 100644 > --- a/notmuch-new.c > +++ b/notmuch-new.c > @@ -39,6 +39,7 @@ typedef struct { > int total_files; > int processed_files; > int added_messages; > + int tag_maildir; I think notmuch_bool_t will be better than int here. BTW what is the reason for using notmuch_bool_t instead of bool from stdbool.h? > @@ -222,6 +277,7 @@ add_files_recursive (notmuch_database_t *notmuch, > notmuch_filenames_t *db_subdirs = NULL; > struct stat st; > notmuch_bool_t is_maildir, new_directory; > + int maildir_detected = -1; Again, notmuch_bool_t is IMHO better. You seem only to use values -1 and 1 which is quite confusing. > > if (stat (path, &st)) { > fprintf (stderr, "Error reading directory %s: %s\n", > @@ -301,6 +357,28 @@ add_files_recursive (notmuch_database_t *notmuch, > continue; > } > > + /* If this directory is a Maildir folder, we need to > + * ignore any subdirectories marked tmp/, and scan for > + * Maildir attributes on messages contained in the sub- > + * directories 'new' and 'cur'. */ > + if (maildir_detected != 0 && > + (entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) && > + ((strcmp (entry->d_name, "tmp") == 0) || > + (strcmp (entry->d_name, "new") == 0) || > + (strcmp (entry->d_name, "cur") == 0))) { > + > + if (maildir_detected == -1) { > + maildir_detected = _entries_resemble_maildir(fs_entries, num_fs_entries); > + } > + if (maildir_detected == 1) { > + if (strcmp (entry->d_name, "tmp") == 0) { > + continue; > + } else { > + state->tag_maildir = TRUE; You might also want to set this to FALSE somewhere. It is very unlikely, but somebody can create non-maildir under maildir. > @@ -412,7 +490,12 @@ add_files_recursive (notmuch_database_t *notmuch, > /* success */ > case NOTMUCH_STATUS_SUCCESS: > state->added_messages++; > - tag_inbox_and_unread (message); > + if (state->tag_maildir) { > + derive_tags_from_maildir_flags (message, > + entry->d_name); > + } else { > + tag_inbox_and_unread (message); > + } > break; > /* Non-fatal issues (go on to next file) */ > case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: You add the tags only to newly discovered mails. If a file is renamed (e.g. because another mail reader removed the S flag), the tags will not be updated. It is a question, what is the proper behavior. I personally use something like what is in your patch and then use notmuchsync to handle renamed files. It has only one problem - notmuchsync is quite slow, so if this is solved in notmuch, I'd be happy. Cheers, Michal