about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-11 00:59:51 +0000
committerEric Wong <e@80x24.org>2019-01-11 03:57:33 +0000
commita6823087e5aa9699a42c31df16323885c70d1b4d (patch)
tree06c2bd190c02e0cc5546cf6385764390486a876b
parent9739f3aa67425958f306f8418c0c6fbf186481c3 (diff)
downloadpublic-inbox-a6823087e5aa9699a42c31df16323885c70d1b4d.tar.gz
v2writable: ->purge returns undef on no-op
And doesn't try to access undef as an array ref.
-rw-r--r--lib/PublicInbox/V2Writable.pm2
-rw-r--r--t/v2writable.t3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 222df5c2..08d18fc0 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -390,7 +390,7 @@ sub purge {
         my ($self, $mime) = @_;
         my $purges = $self->{-inbox}->with_umask(sub {
                 remove_internal($self, $mime, undef, {});
-        });
+        }) or return;
         $self->idx_init if @$purges; # ->done is called on purges
         for my $i (0..$#$purges) {
                 defined(my $cmt = $purges->[$i]) or next;
diff --git a/t/v2writable.t b/t/v2writable.t
index ec9f56d9..f1714175 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -247,6 +247,9 @@ EOF
         ok(my $cmts = $im->purge($mime), 'purged message');
         like($cmts->[0], qr/\A[a-f0-9]{40}\z/, 'purge returned current commit');
         $im->done;
+
+        # again
+        is($im->purge($mime), undef, 'no-op returns undef');
 }
 
 {