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 B0A7F431FBC for ; Sun, 22 Nov 2009 08:20:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 8W8uWjJXaSep for ; Sun, 22 Nov 2009 08:20:12 -0800 (PST) Received: from tau.jukie.net (tau.jukie.net [216.239.93.128]) by olra.theworths.org (Postfix) with ESMTP id B9E1C431FC0 for ; Sun, 22 Nov 2009 08:20:11 -0800 (PST) Received: from localhost.localdomain (oxygen.jukie.net [10.10.10.8]) by tau.jukie.net (Postfix) with ESMTP id 214B2C00F9B; Sun, 22 Nov 2009 11:20:11 -0500 (EST) From: Bart Trojanowski To: notmuch@notmuchmail.org Date: Sun, 22 Nov 2009 11:19:31 -0500 Message-Id: <1258906771-6869-1-git-send-email-bart@jukie.net> X-Mailer: git-send-email 1.6.4.4.2.gc2f148 Subject: [notmuch] [PATCH] fix notmuch-new bug when database path ends with a trailing / X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Sun, 22 Nov 2009 16:20:12 -0000 I configured my database.path with a trailing /, and after running notmuch new every notmuch search would fail with error messages like this: Error opening /inbox/cur/1258565257.000211.mbox:2,S: No such file or directory The actual bug was in the filename normalization for storage in the database. The database.path was removed from the full filename, but if the database.path from the config file contained a trailing /, the relative file name would retain an extra leading /... which made it look like an absolute path after it was read out from the DB. Signed-off-by: Bart Trojanowski --- lib/message.cc | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 017c47b..1e325e2 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -411,10 +411,14 @@ _notmuch_message_set_filename (notmuch_message_t *message, db_path = notmuch_database_get_path (message->notmuch); db_path_len = strlen (db_path); - if (*s == '/' && strncmp (s, db_path, db_path_len) == 0 - && strlen (s) > db_path_len) + if (*s == '/' && strlen (s) > db_path_len + && strncmp (s, db_path, db_path_len) == 0) { - s += db_path_len + 1; + s += db_path_len; + while (*s == '/') s++; + + if (!*s) + INTERNAL_ERROR ("Message filename was same as db prefix."); } message->doc.set_data (s); -- 1.6.4.4.2.gc2f148