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 4F1926DE0C51 for ; Sat, 19 Aug 2017 01:27:38 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.362 X-Spam-Level: X-Spam-Status: No, score=0.362 tagged_above=-999 required=5 tests=[AWL=0.482, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 ul5_K1AV1FBh for ; Sat, 19 Aug 2017 01:27:36 -0700 (PDT) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 5C0526DE0C45 for ; Sat, 19 Aug 2017 01:27:36 -0700 (PDT) Received: by mail-wm0-f65.google.com with SMTP id c14so2235134wmh.1 for ; Sat, 19 Aug 2017 01:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=ewkPfnBgy2nGLvgoUynL/wVhPwmeDInf/paMFwBDomo=; b=I1rOJ9+dqp2OXrtf+7jsdtxogl+XGs3bEhzZUuGOtNNljOy1omyFu3jUe1250UHaAM Le6sY6vuU58NQyQ2JGjsJGKeg9w2rwgn6+7ilC18avjee+MmuYgu04i+oY9J2e82HGkm zrk/wWIZmSjhCapcQCSVL4egDUjEfB8nT4SuFoVE6UsiC75SIA/CFU3IGA9r3mEwxv3Y utgDTUy/y8RQXtSZPSEmpXqt2ZeqU+XoGVGFzH0/QBImNvV/qbTz2G4+40lj07GqN82p 9/kjZoxMkX6CNh5p2IGnswmoMXUhvPgOp8OeiBnagUugYhqoDgqKpdUX/3spp/TQ9gKn c4+w== 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:in-reply-to:references:date :message-id:mime-version; bh=ewkPfnBgy2nGLvgoUynL/wVhPwmeDInf/paMFwBDomo=; b=KE7zil2xYX+Kdk+zpIrb9YMC47lAquripQiS/50bq219Cs3iHkjrJDiZ63P7yfHhyl GWnNm71gC95l3pEuLzEMPtozEpkaXMypx26x/2DYv7548JHMg2qIGa3biqKDvqgUsSd6 l3/3CXPhYcBs92tJd7ensCfjZbLkwk6kDYSdiFYdCRMVdkXOmoYyGpAafbzBwaYrbAUe a0x4isy+cp1CQAxIm9erkznwj4zlZY33MPOYadM+QG74QeGIJwUCDcMgxxot24TIJDYd gKztNEFA0eRcO+8GVv8FAc4sGpfdJ3Ee5lD4rV5nigo7bO7K7YH7HrIxdKAqkGF9GarL Oxeg== X-Gm-Message-State: AHYfb5hL79hGtUkFbVuR4hphtfpp4IkeCu/l7UEGmZDh+0VUy16gdimP PvDUxmAcxvc40Q== X-Received: by 10.28.142.74 with SMTP id q71mr3474057wmd.25.1503131253604; Sat, 19 Aug 2017 01:27:33 -0700 (PDT) Received: from localhost (HSI-KBW-046-005-000-026.hsi8.kabel-badenwuerttemberg.de. [46.5.0.26]) by smtp.gmail.com with ESMTPSA id o30sm8585495wrb.76.2017.08.19.01.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Aug 2017 01:27:33 -0700 (PDT) From: Yuri Volchkov To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/4] insert: strip trailing / in folder path In-Reply-To: <87tw14fm22.fsf@tethera.net> References: <1502556453-11609-1-git-send-email-yuri.volchkov@gmail.com> <1502556453-11609-3-git-send-email-yuri.volchkov@gmail.com> <87tw14fm22.fsf@tethera.net> Date: Sat, 19 Aug 2017 10:27:28 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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: Sat, 19 Aug 2017 08:27:38 -0000 David Bremner writes: > Yuri Volchkov writes: > >> I have faced a problem, that messages sent by emacs could not be shown >> or found later. The "notmuch show id:" says "no such file or >> directory". >> >> The reason of this behavior is the following chain of events: >> 1) While sending a message, emacs calls >> notmuch insert --folder=maildir/Sent/ < test.msg >> > > I think it will be less confusing if you give a more reduced description > of the bug fix here. In particular the test in your previous patch shows > that the neither offlineimap nor multiple copies of a message are needed > to trigger this bug; rather it has to do with insufficient path > canonicalization. You are probably right, I was too obsessed with the problem blocking my switch-to-notmuch project . I'll try to reduce the commit message. >> >> The solution is simple, we have to strip trailing '/' from the insert >> path. >> >> diff --git a/lib/database.cc b/lib/database.cc >> index 8f0e22a..79eb3d6 100644 >> --- a/lib/database.cc >> +++ b/lib/database.cc >> @@ -858,8 +858,7 @@ notmuch_database_open_verbose (const char *path, >> notmuch->status_string = NULL; >> notmuch->path = talloc_strdup (notmuch, path); >> >> - if (notmuch->path[strlen (notmuch->path) - 1] == '/') >> - notmuch->path[strlen (notmuch->path) - 1] = '\0'; >> + strip_trailing(notmuch->path, '/'); > > These seems like a reasonable change, but I don't see the connection > with the notmuch-insert problem. Please either explain the connection in > the commit message or split the change out into a different commit with > an explanation of what it is fixing (and perhaps a seperate test, if > there's a real problem there, rather than just tidying up). This is just for consistency reasons. Fixing my problem required the same piece of code, which was used here. Duplicating is not nice, so I made a function around this code. That's why it feels atomic change to me. I think, explanation like this is superfluously detailed. I can move the introduction of the strip_trailing and cleaning notmuch_database_open_verbose into separate patch, but the fix then will be just a one line. And I'll get unnecessarily tiny patches. What do you think?