From 380a64116a72132610bc7aafdd356ccf3680c277 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins Date: Sun, 3 Nov 2013 11:30:43 +1700 Subject: [PATCH] Re: [PATCH 1/3] database: Add notmuch_database_compact_close --- 3f/350445dd319251b6f0cea1575caca1acf1dbe6 | 148 ++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 3f/350445dd319251b6f0cea1575caca1acf1dbe6 diff --git a/3f/350445dd319251b6f0cea1575caca1acf1dbe6 b/3f/350445dd319251b6f0cea1575caca1acf1dbe6 new file mode 100644 index 000000000..ea8a7c1c9 --- /dev/null +++ b/3f/350445dd319251b6f0cea1575caca1acf1dbe6 @@ -0,0 +1,148 @@ +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 1A348431FBF + for ; Sat, 2 Nov 2013 11:31:03 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3] 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 Q8hI8uwNI80F for ; + Sat, 2 Nov 2013 11:30:55 -0700 (PDT) +Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu + [131.215.239.19]) + by olra.theworths.org (Postfix) with ESMTP id B57B4431FAF + for ; Sat, 2 Nov 2013 11:30:55 -0700 (PDT) +Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) + by fire-doxen-postvirus (Postfix) with ESMTP id 42E6832803B; + Sat, 2 Nov 2013 11:30:55 -0700 (PDT) +X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new +Received: from finestructure.net (cpe-76-173-75-27.socal.res.rr.com + [76.173.75.27]) (Authenticated sender: jrollins) + by fire-doxen-submit (Postfix) with ESMTP id 59DA92E50DF9; + Sat, 2 Nov 2013 11:30:54 -0700 (PDT) +Received: by finestructure.net (Postfix, from userid 1000) + id 9CF2B600B0; Sat, 2 Nov 2013 11:30:45 -0700 (PDT) +From: Jameson Graef Rollins +To: Ben Gamari , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/3] database: Add notmuch_database_compact_close +In-Reply-To: <1380745848-4972-2-git-send-email-bgamari.foss@gmail.com> +References: <1380745848-4972-1-git-send-email-bgamari.foss@gmail.com> + <1380745848-4972-2-git-send-email-bgamari.foss@gmail.com> +User-Agent: Notmuch/0.16+120~gfd733a4 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Sat, 02 Nov 2013 11:30:43 -0700 +Message-ID: <87habuirl8.fsf@servo.finestructure.net> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +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: Sat, 02 Nov 2013 18:31:03 -0000 + +--=-=-= +Content-Type: text/plain + +On Wed, Oct 02 2013, Ben Gamari wrote: +> +/* Compacts the given database, optionally saving the original database +> + * in backup_path. Additionally, a callback function can be provided to +> + * give the user feedback on the progress of the (likely long-lived) +> + * compaction process. +> + * +> + * The backup path must point to a directory on the same volume as the +> + * original database. Passing a NULL backup_path will result in the +> + * uncompacted database being deleted after compaction has finished. +> + * Note that the database write lock will be held during the +> + * compaction process to protect data integrity. +> + */ +> +notmuch_status_t +> +notmuch_database_compact (const char* path, +> + const char* backup_path, +> + notmuch_compact_status_cb_t status_cb) +> +{ +> + void *local = talloc_new (NULL); +> + NotmuchCompactor compactor(status_cb); +> + char *notmuch_path, *xapian_path, *compact_xapian_path; +> + char *old_xapian_path = NULL; +> + notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; +> + notmuch_database_t *notmuch = NULL; +> + struct stat statbuf; +> + +> + ret = notmuch_database_open(path, NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much); +> + if (ret) { +> + goto DONE; +> + } +> + +> + if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) { +> + ret = NOTMUCH_STATUS_OUT_OF_MEMORY; +> + goto DONE; +> + } +> + +> + if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { +> + ret = NOTMUCH_STATUS_OUT_OF_MEMORY; +> + goto DONE; +> + } +> + +> + if (! (compact_xapian_path = talloc_asprintf (local, "%s.compact", xapian_path))) { +> + ret = NOTMUCH_STATUS_OUT_OF_MEMORY; +> + goto DONE; +> + } +> + +> + if (backup_path != NULL) { +> + if (! (old_xapian_path = talloc_asprintf (local, "%s/xapian.old", backup_path))) { +> + ret = NOTMUCH_STATUS_OUT_OF_MEMORY; +> + goto DONE; +> + } + +Hey, folks. I'm obviously late for this, but I just got around to +testing the new compact functionality now and I wanted to comment on the +path for the old xapian directory. It seems to me that + + /xapian.old + +isn't the right place for it. I would think that + + .old + +would be a much better place. I'm not such a fan of dumping internal +notmuch stuff into the main mail directory. Keeping all notmuch stuff +in seems more reasonable and polite. + +jamie. + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.15 (GNU/Linux) + +iQIcBAEBCAAGBQJSdUTTAAoJEO00zqvie6q8bX0P+wXFd5IbVkX1i5vM2NtuGHDC +pgIgnB2RbKIzjTKiZ7LdojjPIkuf0tHFN415mpfsYruJQXQLiUgOtqwb1VIVJNB3 +T3QleWDEzcFN0X8Nh2tDh3nCXa3+/IXWkkp237HR6YaycA5UE18f4Q9Mx6wIHxz7 +SQvGGVFHcnRg5wNVOm3H/bnepJnWYe2j4lrFyDZHcMSq4e6/Ph3vTlIqX8mfznFC +zZ+pArfNGYndT0+oqSSS9ngNlRbFAiOH7KeBUzrNd2igN+MVbdxCj4wxJPzX477Z +GooAAFpQ0QLZSh9kjuzXqDMJAE0J6pUPSnKKt3QP85vUuDqss2g5rw16cFrMKg5Z +bmTPrkbkamuJJlfab45NQo5QcHjPVss4Ov2nycorjhLATEHG3srA1GorY6aG6l6n +MlsGm7S7EQmbtEwVdBW66GtCzbFNExvKSLkY3jXB4CesnsPyRxxH6/uEFDhIKzdf +qoFtnYc5PKOcj8wJu1fyMUM0cc4CdXtSFb/Ukfsx+nIr1gOs2F+3risy/m2SP8u/ +9d6wH1p+TulqmBSIx0w4vjko1HifY8yRMcxgDswdciDVja6CECAPdHUu/RKmlBwl +hyH4ic9RoMGaSSo4TJBwEnzgz3u7pmqonkcqWfnDizL8hxjYS7xKuICWHwjLzSq8 +ajIn9+13a1Zj23+d5Z8e +=KQ4Y +-----END PGP SIGNATURE----- +--=-=-=-- -- 2.26.2