From 9a87b1c6d2ac3607e774e0ae1b6df1217f0821e1 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 25 Sep 2015 23:48:45 +0300 Subject: [PATCH] [PATCH 2/3] lib: add interface to delete directory documents --- df/c8c21a8e9a16d9f6ce92f8e41128bebfa2fbb5 | 138 ++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 df/c8c21a8e9a16d9f6ce92f8e41128bebfa2fbb5 diff --git a/df/c8c21a8e9a16d9f6ce92f8e41128bebfa2fbb5 b/df/c8c21a8e9a16d9f6ce92f8e41128bebfa2fbb5 new file mode 100644 index 000000000..da6b795bb --- /dev/null +++ b/df/c8c21a8e9a16d9f6ce92f8e41128bebfa2fbb5 @@ -0,0 +1,138 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id E6E976DE0C3A + for ; Fri, 25 Sep 2015 13:49:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.528 +X-Spam-Level: +X-Spam-Status: No, score=-0.528 tagged_above=-999 required=5 tests=[AWL=0.192, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] + 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 Sl77b-x0hywe for ; + Fri, 25 Sep 2015 13:49:19 -0700 (PDT) +Received: from mail-la0-f42.google.com (mail-la0-f42.google.com + [209.85.215.42]) + by arlo.cworth.org (Postfix) with ESMTPS id B5E316DE0C4A + for ; Fri, 25 Sep 2015 13:49:11 -0700 (PDT) +Received: by lacrr8 with SMTP id rr8so31609443lac.2 + for ; Fri, 25 Sep 2015 13:49:09 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references:in-reply-to:references; + bh=Hcd2BBXwMAtYuvsaAjNHAvemmryBrHYnZB4BlAjuSIE=; + b=G9WdYX/Yzmb9MY/XWpsgeP8k6lfOKp/dMlvNLNRSbNVgwzmMhqyxvCJK0i/EiRfSvX + 173RkzeyBG4k+Ua27Bn0ikifPiGq6IEsuiEhuJXCkMotm4F6WMehs+pusmRetBM++IPi + RnRf/fHt8uafbAO2D7X03jn7r1BHRi5LEaOJwisabNcNKTfvVOizFTZyiV4rnL6Awhb4 + if2nr5ttOZft9UOsC0/Jh0896I/GtVfV9U3p1PbD/7LQs+els7nSpvtBzxcokaXEspwb + d3zDmjWuj2s5JDE4mYrUzinCbls2XqwK289CyeVgQzHLxjGxU5XmyUYZeehM4Cb3/lXk + 8FmQ== +X-Gm-Message-State: + ALoCoQnEGX/B39Bko27qzAynzjieMMJ6qXHirr5YqmLquB37hZM3eZd4PXJfdr3HxL0lu8Pnmspx +X-Received: by 10.25.210.206 with SMTP id j197mr1488122lfg.86.1443214149081; + Fri, 25 Sep 2015 13:49:09 -0700 (PDT) +Received: from localhost (mobile-access-bcee63-221.dhcp.inet.fi. + [188.238.99.221]) + by smtp.gmail.com with ESMTPSA id a140sm599484lfb.35.2015.09.25.13.49.08 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 25 Sep 2015 13:49:08 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 2/3] lib: add interface to delete directory documents +Date: Fri, 25 Sep 2015 23:48:45 +0300 +Message-Id: + +X-Mailer: git-send-email 2.1.4 +In-Reply-To: +References: +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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, 25 Sep 2015 20:49:21 -0000 + +As mentioned in + +commit acd66cdec075312944e527febd46382e54d99367 +Author: Jani Nikula +Date: Sat Sep 5 12:35:31 2015 +0300 + + cli: reset db directory mtime upon directory removal + +we don't have an interface to delete directory documents, and they're +left behind. Add the interface. + +XXX: Should this also remove the files under it, or assume that's been +done by the caller? Should this incorporate some or all of the +functionality of _remove_directory() in notmuch-new.c? +--- + lib/directory.cc | 18 ++++++++++++++++++ + lib/notmuch.h | 7 +++++++ + 2 files changed, 25 insertions(+) + +diff --git a/lib/directory.cc b/lib/directory.cc +index b836ea2812c8..f23b71769aef 100644 +--- a/lib/directory.cc ++++ b/lib/directory.cc +@@ -281,6 +281,24 @@ notmuch_directory_get_child_directories (notmuch_directory_t *directory) + return child_directories; + } + ++notmuch_status_t ++notmuch_directory_delete (notmuch_directory_t *directory) ++{ ++ notmuch_status_t status; ++ Xapian::WritableDatabase *db; ++ ++ status = _notmuch_database_ensure_writable (directory->notmuch); ++ if (status) ++ return status; ++ ++ db = static_cast (directory->notmuch->xapian_db); ++ db->delete_document (directory->document_id); ++ ++ notmuch_directory_destroy (directory); ++ ++ return NOTMUCH_STATUS_SUCCESS; ++} ++ + void + notmuch_directory_destroy (notmuch_directory_t *directory) + { +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 87756838d072..1feda4521e4d 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -1720,6 +1720,13 @@ notmuch_filenames_t * + notmuch_directory_get_child_directories (notmuch_directory_t *directory); + + /** ++ * Delete directory document from the database, and destroy the ++ * notmuch_directory_t object. ++ */ ++notmuch_status_t ++notmuch_directory_delete (notmuch_directory_t *directory); ++ ++/** + * Destroy a notmuch_directory_t object. + */ + void +-- +2.1.4 + -- 2.26.2