From d58064935f1c66acb7f6d82bde0e14210ed9152b Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 24 May 2012 23:57:45 +0300 Subject: [PATCH] Re: [PATCH v3 3/4] new: Merge error checks from add_files and add_files_recursive --- 3e/8666b25942e598efea992513524aa45b2efc72 | 147 ++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 3e/8666b25942e598efea992513524aa45b2efc72 diff --git a/3e/8666b25942e598efea992513524aa45b2efc72 b/3e/8666b25942e598efea992513524aa45b2efc72 new file mode 100644 index 000000000..2abcf3c44 --- /dev/null +++ b/3e/8666b25942e598efea992513524aa45b2efc72 @@ -0,0 +1,147 @@ +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 A5311431E62 + for ; Thu, 24 May 2012 13:57:48 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=unavailable +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 QQeorfyckHPO for ; + Thu, 24 May 2012 13:57:48 -0700 (PDT) +Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com + [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3F4CA431FBD + for ; Thu, 24 May 2012 13:57:48 -0700 (PDT) +Received: by mail-lb0-f181.google.com with SMTP id gk8so179779lbb.26 + for ; Thu, 24 May 2012 13:57:47 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type:x-gm-message-state; + bh=coa1rnBnz553nybF0VZC4Z++LLTJzrA4mctnfpAOhvY=; + b=DkqxR2V6z8guI9XUA8b4ll46GEk3KsC+b6mBExhhM+8u1whJhY24rnNQjcwXyBkP35 + s36eMvoWnWqfN3vI+cr80CEYHM6wKsm7YdBqVpDzTThN4BJvZUKuPXxmtop+hDFKXUvu + T/fT7dfBr+8Qzd1DQftJJHT94UCRuQMrX/c22Im6C24cPeVfNFDnO4M+0hx+OxjAqCvX + LADyBtwiaFwSYxVfyICGm8b4fQd8IqZ2u94UuFDGmkH5pGFf4hd2aJEa2Rlbvi6T8kOE + TN8Rna8HlsmpxzlbV5JfGzSEwfLE3EP3P/XxPF4jddFQFQnxOD3QsuPV6dB5VaPeMCLe + nqOA== +Received: by 10.112.48.2 with SMTP id h2mr383590lbn.61.1337893067767; + Thu, 24 May 2012 13:57:47 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi. + [80.220.80.68]) + by mx.google.com with ESMTPS id h9sm1878668lbi.9.2012.05.24.13.57.46 + (version=SSLv3 cipher=OTHER); Thu, 24 May 2012 13:57:47 -0700 (PDT) +From: Jani Nikula +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 3/4] new: Merge error checks from add_files and + add_files_recursive +In-Reply-To: <1337887922-13163-4-git-send-email-amdragon@mit.edu> +References: <1336429240-1114-1-git-send-email-amdragon@mit.edu> + <1337887922-13163-1-git-send-email-amdragon@mit.edu> + <1337887922-13163-4-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.13+13~gc259b9a (http://notmuchmail.org) Emacs/23.3.1 + (i686-pc-linux-gnu) +Date: Thu, 24 May 2012 23:57:45 +0300 +Message-ID: <87vcjl5mba.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Gm-Message-State: + ALoCoQkuVJALtcdTBqvFIf7EB0ujgh65AXds2GVydZDES61EJ29/+1XjstPMq+pWgsdy4Nj2serx +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: Thu, 24 May 2012 20:57:48 -0000 + +On Thu, 24 May 2012, Austin Clements wrote: +> Before XXX, add_files_recursive could have been called on a symlink to +> a non-directory. Hence, calling it on a non-directory was not an +> error, so a separate function, add_files, existed to fail loudly in +> situations where the path had to be a directory. + +"Before XXX"? + +Otherwise, this 3/4 and following 4/4 patch LGTM. I didn't bother +looking at 1/4 and 2/4 again, as you say there were no changes. + + +BR, +Jani. + + +> +> With the new stat-ing logic, add_files_recursive is always called on +> directories, so the separation of this logic is no longer necessary. +> Hence, this patch moves the strict error checking previously done by +> add_files into add_files_recursive. +> --- +> notmuch-new.c | 27 +++++---------------------- +> 1 file changed, 5 insertions(+), 22 deletions(-) +> +> diff --git a/notmuch-new.c b/notmuch-new.c +> index c64f1a7..2b05605 100644 +> --- a/notmuch-new.c +> +++ b/notmuch-new.c +> @@ -308,11 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch, +> } +> stat_time = time (NULL); +> +> - /* This is not an error since we may have recursed based on a +> - * symlink to a regular file, not a directory, and we don't know +> - * that until this stat. */ +> - if (! S_ISDIR (st.st_mode)) +> - return NOTMUCH_STATUS_SUCCESS; +> + if (! S_ISDIR (st.st_mode)) { +> + fprintf (stderr, "Error: %s is not a directory.\n", path); +> + return NOTMUCH_STATUS_FILE_ERROR; +> + } +> +> fs_mtime = st.st_mtime; +> +> @@ -655,23 +654,7 @@ add_files (notmuch_database_t *notmuch, +> const char *path, +> add_files_state_t *state) +> { +> - notmuch_status_t status; +> - struct stat st; +> - +> - if (stat (path, &st)) { +> - fprintf (stderr, "Error reading directory %s: %s\n", +> - path, strerror (errno)); +> - return NOTMUCH_STATUS_FILE_ERROR; +> - } +> - +> - if (! S_ISDIR (st.st_mode)) { +> - fprintf (stderr, "Error: %s is not a directory.\n", path); +> - return NOTMUCH_STATUS_FILE_ERROR; +> - } +> - +> - status = add_files_recursive (notmuch, path, state); +> - +> - return status; +> + return add_files_recursive (notmuch, path, state); +> } +> +> /* XXX: This should be merged with the add_files function since it +> -- +> 1.7.10 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2