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 86FFA431FD0 for ; Fri, 9 Sep 2011 16:40:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 oclb3xmcfdvS for ; Fri, 9 Sep 2011 16:40:11 -0700 (PDT) Received: from mail-qw0-f43.google.com (mail-qw0-f43.google.com [209.85.216.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D8300431FB6 for ; Fri, 9 Sep 2011 16:40:11 -0700 (PDT) Received: by qwm42 with SMTP id 42so2072631qwm.2 for ; Fri, 09 Sep 2011 16:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=nSsbqrf/JLGaZKgaMBRZNiiCcRPVTfGvndp2I8bSLaU=; b=eSxVZp4vVMe7Hm0uTcCHzdGPRlLogS9B9QNZBfOo9F/QGLoJCCoD4j9c+fQkbk87Bx UHixNtc6XdNr1+hIWN7TD/muGLCEy6u08cgeAkor3v72Jm93WZfGiWM3k/jlAOtaRF2w kTJF4lJcFLnoaUPQgPJ2xG9UYry2Z1L//PY6Y= MIME-Version: 1.0 Received: by 10.229.67.148 with SMTP id r20mr1933245qci.64.1315611610161; Fri, 09 Sep 2011 16:40:10 -0700 (PDT) Sender: amdragon@gmail.com Received: by 10.229.2.201 with HTTP; Fri, 9 Sep 2011 16:40:10 -0700 (PDT) In-Reply-To: <1315590950.2435.59.camel@delen> References: <1315445674.32058.183.camel@delen> <1315536861.2435.34.camel@delen> <87obyuj7q1.fsf@zancas.localnet> <1315590950.2435.59.camel@delen> Date: Fri, 9 Sep 2011 19:40:10 -0400 X-Google-Sender-Auth: NviPvfwSvnlBQa1dzgFj2mYRhZc Message-ID: Subject: Re: Patch: Flush and Reopen From: Austin Clements To: Martin Owens Content-Type: text/plain; charset=ISO-8859-1 Cc: Notmuch developer list 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: Fri, 09 Sep 2011 23:40:12 -0000 On Fri, Sep 9, 2011 at 1:55 PM, Martin Owens wrote: > That probably was unintended. See attached for the all new slimmed down > patch. --- a/lib/database.cc +++ b/lib/database.cc @@ -700,18 +700,37 @@ notmuch_database_open (const char *path, } void -notmuch_database_close (notmuch_database_t *notmuch) +notmuch_database_reopen (notmuch_database_t *notmuch) { try { - if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE) - (static_cast (notmuch->xapian_db))->flush (); + if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) + (static_cast (notmuch->xapian_db))->reopen(); I was thinking this should probably just be try { notmuch->xapian_db->reopen (); } catch ... (indented correctly, of course). Reopen is a method of Xapian::Database, which is what notmuch->xapian_db is anyway (unlike, flush, which is a member of the subclass WritableDatabase and hence requires the cast). And reopening is a sensible thing to do on both read-only and read/write databases. Also, in keeping with notmuch code style, you should use tabs for indentation and put a space before the open paren argument lists.