From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 1C79D6DE1152 for ; Mon, 21 Aug 2017 08:45:02 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.311 X-Spam-Level: X-Spam-Status: No, score=-0.311 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AFSEtnhHJjQl for ; Mon, 21 Aug 2017 08:45:01 -0700 (PDT) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by arlo.cworth.org (Postfix) with ESMTPS id 0FA116DE11B3 for ; Mon, 21 Aug 2017 08:45:00 -0700 (PDT) Received: by mail-wr0-f193.google.com with SMTP id f8so13178037wrf.3 for ; Mon, 21 Aug 2017 08:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=ADrF79mYye7NxNWnfZtfAXVbel+goIpa1n53oPHk6+8=; b=jmmbHGSp6RpuNeQUyE1PuRlERjUu8I3SsyGC4sad8vJhLTaeM/9TeDAwK6pockri1O HGdDc43G0yNOXRdPk7mDrGELlYttxfP+2UHVSmmiof9HPNXGyh2waXZ916xlyicqpyYS wC8kNVqvtCZ56NAcVimxYhP2R93zH6QNGjhKKP2ybqW5l8QVTYJUElY24pomQ5ApD9dj /T1VOiUABHqxhHVVwvhTCPMt4Q+CoylJAWKwDG7S3IW9bSOEM4dDwlNS3f7LIn7Cm18V 0VhiRlyprZP/I5nCMNkx3bMUGAC0h9aRD6GX3sk9kftngtl7TINucqxAQ+sbibk93Suh yK9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ADrF79mYye7NxNWnfZtfAXVbel+goIpa1n53oPHk6+8=; b=kfKf4J9gHm3PCrFmhajhlKvhU4ODRCwxU+6aArwnyyCqp9nDoy22Hx5djgIm8S0+XF bU+A/svBBb+xlNC6k7FXKcGm3xcDaviWLsv2EFUS8YUUSZ5LDhYz5h1prRSJV7kRXHlD 0V2dbJPwJtuJEr9wZtWfFtT87YtOdtSTZPtnjkiwV9rqC1phkeWbQcYbfcA4FE3Qzyub O7LOIhLtr9sIzUVQOea9UrvL/B44ZlNpfsdhVRZhlgeOFYD8HDTEtBpkxPowGROdAX6C PdIygMsACOJE/RBMSQitLNJAb1B9qMTEzY2Cblse3+6udGyGin3ZR1ZFz7Bf5ftq53LS MsQQ== X-Gm-Message-State: AHYfb5i2nH0wYKtVsS8iiFZ8eHE66Xv54TyVjTFpFvdu/h4MlQX2e0S0 4hCmt+BtM56+0NiNTSg= X-Received: by 10.223.174.89 with SMTP id u25mr7936911wrd.228.1503330298476; Mon, 21 Aug 2017 08:44:58 -0700 (PDT) Received: from localhost (mito.neclab.eu. [195.37.70.39]) by smtp.gmail.com with ESMTPSA id e5sm3390974wma.31.2017.08.21.08.44.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 08:44:58 -0700 (PDT) From: Yuri Volchkov To: notmuch@notmuchmail.org Subject: [PATCH v2 2/4] insert: strip trailing / in folder path Date: Mon, 21 Aug 2017 17:44:46 +0200 Message-Id: <1503330288-9375-3-git-send-email-yuri.volchkov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503330288-9375-1-git-send-email-yuri.volchkov@gmail.com> References: <1502556453-11609-1-git-send-email-yuri.volchkov@gmail.com> <1503330288-9375-1-git-send-email-yuri.volchkov@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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: Mon, 21 Aug 2017 15:45:02 -0000 This patch fixes the "Insert message into folder with trailing /" test. The problem was insufficient path canonization. >From database's point of view, "Sent" and "Sent/" are different folders. If user runs (note the last '/'): notmuch insert --folder=maildir/Sent/ < test.msg notmuch will create an extra XDIRECTORY record for the folder 'Sent/'. This means that database will have _TWO_ records for _ONE_ physical folder: 'Sent' and 'Sent/'. However, the 'notmuch new' command will update only records related to the first one (the correct one). Now, if user moved the email file (e.g. from 'Sent/new' to 'Sent/cur'), 'notmuch new' will add a record about the new file, but will not delete the old record. Signed-off-by: Yuri Volchkov --- notmuch-insert.c | 4 +++- test/T070-insert.sh | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index bc96af0..2590e83 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -27,6 +27,7 @@ #include #include #include +#include "string-util.h" static volatile sig_atomic_t interrupted; @@ -451,7 +452,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) size_t new_tags_length; tag_op_list_t *tag_ops; char *query_string = NULL; - const char *folder = NULL; + char *folder = NULL; notmuch_bool_t create_folder = FALSE; notmuch_bool_t keep = FALSE; notmuch_bool_t no_hooks = FALSE; @@ -511,6 +512,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) if (folder == NULL) { maildir = db_path; } else { + strip_trailing (folder, '/'); if (! is_valid_folder_name (folder)) { fprintf (stderr, "Error: invalid folder name: '%s'\n", folder); return EXIT_FAILURE; diff --git a/test/T070-insert.sh b/test/T070-insert.sh index 187dfd3..380934a 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -133,7 +133,6 @@ dirname=$(dirname "$output") test_expect_equal "$dirname" "$MAIL_DIR/Drafts/new" test_begin_subtest "Insert message into folder with trailing /" -test_subtest_known_broken gen_insert_msg notmuch insert --folder=Drafts/ < "$gen_msg_filename" output=$(notmuch search --output=files id:${gen_msg_id}) -- 2.7.4