From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9CE3A1FAF5 for ; Mon, 19 Mar 2018 08:15:04 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 21/27] v2writable: ensure ->done is idempotent Date: Mon, 19 Mar 2018 08:14:53 +0000 Message-Id: <20180319081459.10645-22-e@80x24.org> In-Reply-To: <20180319081459.10645-1-e@80x24.org> References: <20180319081459.10645-1-e@80x24.org> List-Id: This matches Import::done behavior --- lib/PublicInbox/V2Writable.pm | 3 ++- t/v2writable.t | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 36901cd..5c104d8 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -249,10 +249,11 @@ sub remove { sub done { my ($self) = @_; + my $locked = defined $self->{idx_parts}; my $im = delete $self->{im}; $im->done if $im; # PublicInbox::Import::done $self->searchidx_checkpoint(0); - $self->lock_release; + $self->lock_release if $locked; } sub checkpoint { diff --git a/t/v2writable.t b/t/v2writable.t index 5245a84..771e8c1 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -223,6 +223,8 @@ EOF $im->done; is($git0->qx(qw(log -1 --pretty=raw --raw -r --no-abbrev)), $after, 'no git history made with idempotent remove'); + eval { $im->done }; + ok(!$@, '->done is idempotent'); } done_testing(); -- EW