Re: [PATCH v3 01/20] cli: add stub for insert command
authorPeter Wang <novalazy@gmail.com>
Wed, 23 Jan 2013 08:04:24 +0000 (19:04 +1100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:19 +0000 (09:53 -0800)
53/2ee6448c387350595817b6dbc136cfaf6d9b38 [new file with mode: 0644]

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