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 53828431FAF for ; Wed, 23 Jan 2013 00:04:33 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 KOcRMQ7IBIqg for ; Wed, 23 Jan 2013 00:04:32 -0800 (PST) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 87B5C431FAE for ; Wed, 23 Jan 2013 00:04:32 -0800 (PST) Received: by mail-pa0-f42.google.com with SMTP id rl6so4637742pac.1 for ; Wed, 23 Jan 2013 00:04:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:message-id:from:to:cc:subject:in-reply-to :references:mime-version:content-type:content-disposition :content-transfer-encoding; bh=CX72w5YPg+L5328OWEQqhlhCHBu8scxfrZ9EQdPSS0Y=; b=xJ4E4IRl/vpYHODtNKCDZiPLIhY0IIlUUCj3a3WQqBPY9YHruwfJM1Ir+KBU71YLIj e4E8xj9up9Wmlj9kbHC5RIMEg8RxWQk07l786YXcQdAvZ3P8+f53KdMuNqPjnNouo+QW 30QS6Xuk+dav6eYUBg/BQazNnk+zCdprqxDztnkaSqOmaDqUgRzzO2eZzp6kAlJtUIRq myxmbn2eOSbBgjc7lis4fk3EcN1UFEDHpAKfP5YNhaWk/EGWQZWxnO7IvksNCW0cTYwV 9GohcBr27gOpC5kVa8RHqblYcTAlNBNv3iKmEQczE6yD1MosQgJAI0ewQQsUWmlxOPkh uzAg== X-Received: by 10.66.76.37 with SMTP id h5mr2381731paw.33.1358928270668; Wed, 23 Jan 2013 00:04:30 -0800 (PST) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id qn3sm12357330pbb.56.2013.01.23.00.04.27 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 23 Jan 2013 00:04:29 -0800 (PST) Date: Wed, 23 Jan 2013 19:04:24 +1100 Message-ID: <20130123190424.GA1980@hili.localdomain> From: Peter Wang To: Jani Nikula Subject: Re: [PATCH v3 01/20] cli: add stub for insert command In-Reply-To: <87vcaoj3i0.fsf@nikula.org> References: <1358643004-14522-1-git-send-email-novalazy@gmail.com> <1358643004-14522-2-git-send-email-novalazy@gmail.com> <87vcaoj3i0.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Cc: notmuch@notmuchmail.org 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: Wed, 23 Jan 2013 08:04:33 -0000 On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula wrote: > > Though it could be used as an alternative to notmuch new, the reason > > I want this is to allow my notmuch frontend to add postponed or sent > > messages to the mail store and notmuch database, without resorting to > > another tool (e.g. notmuch-deliver) nor directly modifying the maildir. > > This review is based on the following patches squashed together: > > cli: add stub for insert command > insert: open Maildir tmp file > insert: copy stdin to Maildir tmp file > insert: move file from Maildir tmp to new > insert: add new message to database > insert: apply default tags to new message > insert: parse and apply command-line tag operations > insert: fsync after writing tmp file > insert: trap SIGINT and clean up > insert: add copyright line from notmuch-deliver > > It's much easier for me to grasp the big picture this way. > So there *is* a limit to how fine-grained notmuchers want their patches ;-) > > +static notmuch_bool_t > > +maildir_move_tmp_to_new (const char *tmppath, const char *newpath) > > +{ > > + if (rename (tmppath, newpath) != 0) { > > + fprintf (stderr, "Error: rename() failed: %s\n", strerror (errno)); > > + return FALSE; > > + } > > + > > + return TRUE; > > +} > > IMO you could just use rename() inline in the caller, without a wrapper. A subsequent patch fsyncs the directory here. > > +/* Copy the contents of standard input (fdin) into fdout. */ > > +static notmuch_bool_t > > +copy_stdin (int fdin, int fdout) > > The comment and the function name imply the function has something to do > with stdin, while it only cares about file descriptors. Tomi pointed out that the error message refers to standard input. > > +/* Add the specified message file to the notmuch database, applying tags. > > + * The file is renamed to encode notmuch tags as maildir flags. */ > > +static notmuch_bool_t > > +add_file_to_database (notmuch_database_t *notmuch, const char *path, > > + tag_op_list_t *tag_ops) > > +{ > > + 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"); > > This is not uncommon. Why the warning? > I put in the warning because I wasn't sure, then forgot to revisit it. > Also, notmuch new does not apply new.tags in this case. Are you sure we > want to do that here? (You get mail, you read and archive it, you get > the dupe, it pops up unread in your inbox again.) Should command-line tags to be applied to duplicate messages? I'm thinking not. I'll fix the other problems you found. Peter