[PATCH 05/11] cli/insert: clean up sync_dir
authorJani Nikula <jani@nikula.org>
Mon, 22 Sep 2014 09:54:56 +0000 (11:54 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:39 +0000 (10:04 -0800)
53/c12d713b2e8d1018d65b94e44a3a775f61d52f [new file with mode: 0644]

diff --git a/53/c12d713b2e8d1018d65b94e44a3a775f61d52f b/53/c12d713b2e8d1018d65b94e44a3a775f61d52f
new file mode 100644 (file)
index 0000000..40dd055
--- /dev/null
@@ -0,0 +1,112 @@
+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 09B41431FC0\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:55:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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 uIELfe9UHaFi for <notmuch@notmuchmail.org>;\r
+       Mon, 22 Sep 2014 02:55:05 -0700 (PDT)\r
+Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com\r
+ [74.125.82.42])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 689DD431FD6   for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:54:55 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f42.google.com with SMTP id a1so2348556wgh.1\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:54:54 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=g252OVOEA7aR4wJyrkyAhoI1GVvMzteOx09BSIxMPzk=;\r
+       b=XMH63M7Fr9d17VNBQjKKbihD5tMCLGqZVq8G7pvNAy8kER4Xv00BSDOCWLarJw9Vmg\r
+       dV7SatSzeJV2MwvMNqniaSC7Ckui5N/bUotX9mbeVIIogfL/t1JMYfpyNQocMX9iH2ck\r
+       saMOO/+hgYUvbkBOxA20VHF1FqxPDTVq1o31cVElouhh2mTHkGCr5gjDw52gKQuRfDpd\r
+       zDoJIknVv5DjVPNu12W6o7YxtXrxOsbcoH2ahr01M2jwGGtf8Xf3cc9Gpd01DU6mSVYf\r
+       r65AJ8jUQlWB7uwoggJLZjR2yljkt6Y3KgaQKuY2gVqh/L0Ab1XfxvtB/PvUEVwrV/jo\r
+       6CHw==\r
+X-Gm-Message-State:\r
+ ALoCoQmE8xaQ1SjEe/i3zIsw92SFN0YbloD0bceJaWOx7H4Xvqiwj4QvZQEZjjCZkf9zVDWqf6Pf\r
+X-Received: by 10.180.100.167 with SMTP id ez7mr13932016wib.14.1411379694347; \r
+       Mon, 22 Sep 2014 02:54:54 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPSA id\r
+       mx19sm11505404wic.3.2014.09.22.02.54.53 for <multiple recipients>\r
+       (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
+       Mon, 22 Sep 2014 02:54:53 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 05/11] cli/insert: clean up sync_dir\r
+Date: Mon, 22 Sep 2014 11:54:56 +0200\r
+Message-Id:\r
+ <7d3e24291b8d4cc0d11b1a87249bbebed4e78648.1411379395.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.2.5\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.org>\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.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: Mon, 22 Sep 2014 09:55:10 -0000\r
+\r
+Clarify the code slightly, improve error messages. Apart from the\r
+error message changes, no functional changes.\r
+---\r
+ notmuch-insert.c |   17 +++++++++--------\r
+ 1 files changed, 9 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+index 5d47806..7375c54 100644\r
+--- a/notmuch-insert.c\r
++++ b/notmuch-insert.c\r
+@@ -67,20 +67,21 @@ safe_gethostname (char *hostname, size_t len)\r
+ static notmuch_bool_t\r
+ sync_dir (const char *dir)\r
+ {\r
+-    notmuch_bool_t ret;\r
+-    int fd;\r
++    int fd, r;\r
\r
+     fd = open (dir, O_RDONLY);\r
+     if (fd == -1) {\r
+-      fprintf (stderr, "Error: open() dir failed: %s\n", strerror (errno));\r
++      fprintf (stderr, "Error: open %s: %s\n", dir, strerror (errno));\r
+       return FALSE;\r
+     }\r
+-    ret = (fsync (fd) == 0);\r
+-    if (! ret) {\r
+-      fprintf (stderr, "Error: fsync() dir failed: %s\n", strerror (errno));\r
+-    }\r
++\r
++    r = fsync (fd);\r
++    if (r)\r
++      fprintf (stderr, "Error: fsync %s: %s\n", dir, strerror (errno));\r
++\r
+     close (fd);\r
+-    return ret;\r
++\r
++    return r == 0;\r
+ }\r
\r
+ /*\r
+-- \r
+1.7.2.5\r
+\r