Re: [PATCH v3 3/4] new: Merge error checks from add_files and add_files_recursive
authorJani Nikula <jani@nikula.org>
Thu, 24 May 2012 21:08:55 +0000 (00:08 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:20 +0000 (09:47 -0800)
e8/273f11bd941392efae6f28f6c4ba65a17110e4 [new file with mode: 0644]

diff --git a/e8/273f11bd941392efae6f28f6c4ba65a17110e4 b/e8/273f11bd941392efae6f28f6c4ba65a17110e4
new file mode 100644 (file)
index 0000000..f80433d
--- /dev/null
@@ -0,0 +1,162 @@
+Return-Path: <jani@nikula.org>\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 2C7CB431FDB\r
+       for <notmuch@notmuchmail.org>; Thu, 24 May 2012 14:09:01 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 OWP8UL8fsM8Y for <notmuch@notmuchmail.org>;\r
+       Thu, 24 May 2012 14:09:00 -0700 (PDT)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 5C23F431FBD\r
+       for <notmuch@notmuchmail.org>; Thu, 24 May 2012 14:09:00 -0700 (PDT)\r
+Received: by lagu2 with SMTP id u2so180288lag.26\r
+       for <notmuch@notmuchmail.org>; Thu, 24 May 2012 14:08:58 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type:x-gm-message-state;\r
+       bh=QWGkLaCJcx6tAYGKXDWNczs6wqW6D9oiErUOjt47wyY=;\r
+       b=V+dVYbBRruEmHKV8CFKwTVL4rRNafwBRlwOFp29n3ymluVBpM3P/eoO3Z2rMNwqmTz\r
+       aJOqkE8zs+mucX1iJo0XdJUMnoJj6VGspebVg2ECufwiHcLhKcxLOX+T1Bhs76gRecbY\r
+       LU8imchtKcielLST6eeRKBtXVi1iIQtch8d+xTzJFSNgeCdiri2ukVx3ZulteJ1UHe7X\r
+       SFLlm8Vg8yVYwkIxDTN+WA1e+D5592fnPih0jG/r8O2O7m55nhS7R2VqH+BzaOiwAuyc\r
+       ZKg2LC0AcFJaB03MDVYPiyKxvLgqB0VnbOHX8teimRFcMbOtQtWbJRNc19u0/mFPgo1A\r
+       TuKQ==\r
+Received: by 10.112.40.36 with SMTP id u4mr390266lbk.70.1337893738716;\r
+       Thu, 24 May 2012 14:08:58 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.\r
+       [80.220.80.68])\r
+       by mx.google.com with ESMTPS id k4sm1888807lbb.12.2012.05.24.14.08.56\r
+       (version=SSLv3 cipher=OTHER); Thu, 24 May 2012 14:08:57 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v3 3/4] new: Merge error checks from add_files and\r
+       add_files_recursive\r
+In-Reply-To: <87vcjl5mba.fsf@nikula.org>\r
+References: <1336429240-1114-1-git-send-email-amdragon@mit.edu>\r
+       <1337887922-13163-1-git-send-email-amdragon@mit.edu>\r
+       <1337887922-13163-4-git-send-email-amdragon@mit.edu>\r
+       <87vcjl5mba.fsf@nikula.org>\r
+User-Agent: Notmuch/0.13+13~gc259b9a (http://notmuchmail.org) Emacs/23.3.1\r
+       (i686-pc-linux-gnu)\r
+Date: Fri, 25 May 2012 00:08:55 +0300\r
+Message-ID: <87sjep5lso.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Gm-Message-State:\r
+ ALoCoQknAn49lUPiNRjduXdvlOTD3UOUGDakMwsINEak1XOHMGUpCMUMKMvCge7PVsWKRRxUVwS1\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: Thu, 24 May 2012 21:09:01 -0000\r
+\r
+\r
+Grrh, sorry for the spam. My favourite MUA told me:\r
+\r
+"Sending...failed to WARNING: gnome-keyring:: couldn't connect to:\r
+/tmp/keyring-Ky8i5h/pkcs11: No such file or directory"\r
+\r
+but sent the message anyway. Apparently msmpt tries to chat with the\r
+gnome-keyring-daemon even though that should not happen per the man\r
+page, and would be unnecessary and useless anyway.\r
+\r
+J.\r
+\r
+\r
+On Thu, 24 May 2012, Jani Nikula <jani@nikula.org> wrote:\r
+> On Thu, 24 May 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+>> Before XXX, add_files_recursive could have been called on a symlink to\r
+>> a non-directory.  Hence, calling it on a non-directory was not an\r
+>> error, so a separate function, add_files, existed to fail loudly in\r
+>> situations where the path had to be a directory.\r
+>\r
+> "Before XXX"?\r
+>\r
+> Otherwise, this 3/4 and following 4/4 patch LGTM. I didn't bother\r
+> looking at 1/4 and 2/4 again, as you say there were no changes.\r
+>\r
+>\r
+> BR,\r
+> Jani.\r
+>\r
+>\r
+>>\r
+>> With the new stat-ing logic, add_files_recursive is always called on\r
+>> directories, so the separation of this logic is no longer necessary.\r
+>> Hence, this patch moves the strict error checking previously done by\r
+>> add_files into add_files_recursive.\r
+>> ---\r
+>>  notmuch-new.c |   27 +++++----------------------\r
+>>  1 file changed, 5 insertions(+), 22 deletions(-)\r
+>>\r
+>> diff --git a/notmuch-new.c b/notmuch-new.c\r
+>> index c64f1a7..2b05605 100644\r
+>> --- a/notmuch-new.c\r
+>> +++ b/notmuch-new.c\r
+>> @@ -308,11 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+>>      }\r
+>>      stat_time = time (NULL);\r
+>>  \r
+>> -    /* This is not an error since we may have recursed based on a\r
+>> -     * symlink to a regular file, not a directory, and we don't know\r
+>> -     * that until this stat. */\r
+>> -    if (! S_ISDIR (st.st_mode))\r
+>> -   return NOTMUCH_STATUS_SUCCESS;\r
+>> +    if (! S_ISDIR (st.st_mode)) {\r
+>> +   fprintf (stderr, "Error: %s is not a directory.\n", path);\r
+>> +   return NOTMUCH_STATUS_FILE_ERROR;\r
+>> +    }\r
+>>  \r
+>>      fs_mtime = st.st_mtime;\r
+>>  \r
+>> @@ -655,23 +654,7 @@ add_files (notmuch_database_t *notmuch,\r
+>>        const char *path,\r
+>>        add_files_state_t *state)\r
+>>  {\r
+>> -    notmuch_status_t status;\r
+>> -    struct stat st;\r
+>> -\r
+>> -    if (stat (path, &st)) {\r
+>> -   fprintf (stderr, "Error reading directory %s: %s\n",\r
+>> -            path, strerror (errno));\r
+>> -   return NOTMUCH_STATUS_FILE_ERROR;\r
+>> -    }\r
+>> -\r
+>> -    if (! S_ISDIR (st.st_mode)) {\r
+>> -   fprintf (stderr, "Error: %s is not a directory.\n", path);\r
+>> -   return NOTMUCH_STATUS_FILE_ERROR;\r
+>> -    }\r
+>> -\r
+>> -    status = add_files_recursive (notmuch, path, state);\r
+>> -\r
+>> -    return status;\r
+>> +    return add_files_recursive (notmuch, path, state);\r
+>>  }\r
+>>  \r
+>>  /* XXX: This should be merged with the add_files function since it\r
+>> -- \r
+>> 1.7.10\r
+>>\r
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r