Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 42776431FB6 for ; Sun, 18 Nov 2012 09:00:25 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled 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 zlvU3+6u7l7p for ; Sun, 18 Nov 2012 09:00:23 -0800 (PST) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E2ABF431FAF for ; Sun, 18 Nov 2012 09:00:22 -0800 (PST) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1Ta8EH-0005Ut-3R; Sun, 18 Nov 2012 17:00:21 +0000 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1Ta8EG-0003Pr-P3; Sun, 18 Nov 2012 17:00:20 +0000 From: Mark Walters To: Peter Wang , notmuch@notmuchmail.org Subject: Re: [PATCH 06/18] insert: add new message to database In-Reply-To: <1343223767-9812-6-git-send-email-novalazy@gmail.com> References: <1343223767-9812-1-git-send-email-novalazy@gmail.com> <1343223767-9812-6-git-send-email-novalazy@gmail.com> User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sun, 18 Nov 2012 17:00:19 +0000 Message-ID: <87txsmq21o.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 27ed630b0fd6a349f6b9f6310687338f (of first 20000 bytes) X-SpamAssassin-Score: -1.8 X-SpamAssassin-SpamBar: - X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -1.8 points. Summary of the scoring: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [138.37.6.40 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * 0.5 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sun, 18 Nov 2012 17:00:25 -0000 Hi On Wed, 25 Jul 2012, Peter Wang wrote: > Add the new message to the notmuch database, renaming the file to encode > notmuch tags as maildir flags. > --- > notmuch-insert.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 44 insertions(+), 0 deletions(-) > > diff --git a/notmuch-insert.c b/notmuch-insert.c > index bab1fed..dd449bc 100644 > --- a/notmuch-insert.c > +++ b/notmuch-insert.c > @@ -129,6 +129,42 @@ copy_fd_data (int fdin, int fdout) > } > > static notmuch_bool_t > +save_database (notmuch_database_t *notmuch, const char *path) I would prefer a different name here: save_database suggests to me that it is a "whole database" operation, whereas it is actually just adding a single message. Maybe add_message or notmuch_insert_add_message? Best wishes Mark > +{ > + notmuch_message_t *message; > + notmuch_status_t status; > + > + status = notmuch_database_add_message (notmuch, path, &message); > + switch (status) { > + case NOTMUCH_STATUS_SUCCESS: > + break; > + case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: > + fprintf (stderr, "Warning: duplicate message.\n"); > + break; > + default: > + case NOTMUCH_STATUS_FILE_NOT_EMAIL: > + case NOTMUCH_STATUS_READ_ONLY_DATABASE: > + case NOTMUCH_STATUS_XAPIAN_EXCEPTION: > + case NOTMUCH_STATUS_OUT_OF_MEMORY: > + case NOTMUCH_STATUS_FILE_ERROR: > + case NOTMUCH_STATUS_NULL_POINTER: > + case NOTMUCH_STATUS_TAG_TOO_LONG: > + case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: > + case NOTMUCH_STATUS_UNBALANCED_ATOMIC: > + case NOTMUCH_STATUS_LAST_STATUS: > + fprintf (stderr, "Error: failed to add `%s' to notmuch database: %s\n", > + path, notmuch_status_to_string (status)); > + return FALSE; > + } > + > + notmuch_message_tags_to_maildir_flags (message); > + > + notmuch_message_destroy (message); > + > + return TRUE; > +} > + > +static notmuch_bool_t > insert_message (void *ctx, notmuch_database_t *notmuch, int fdin, > const char *dir) > { > @@ -152,6 +188,14 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin, > > if (!ret) { > unlink (tmppath); > + return FALSE; > + } > + > + ret = save_database (notmuch, newpath); > + > + if (!ret) { > + /* XXX maybe there should be an option to keep the file in maildir? */ > + unlink (newpath); > } > > return ret; > -- > 1.7.4.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch