]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: ->purge returns undef on no-op
authorEric Wong <e@80x24.org>
Fri, 11 Jan 2019 00:59:51 +0000 (00:59 +0000)
committerEric Wong <e@80x24.org>
Fri, 11 Jan 2019 03:57:33 +0000 (03:57 +0000)
And doesn't try to access undef as an array ref.

lib/PublicInbox/V2Writable.pm
t/v2writable.t

index 222df5c2ffa6d0cf3dae884ea734ee9973dc1619..08d18fc099a25f340432f0ad01ce22ad6f40666e 100644 (file)
@@ -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;
index ec9f56d91657dbc50d5f97d72874075f8f6b4d3f..f171417513440fb578382a1471ba3e13544af26c 100644 (file)
@@ -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');
 }
 
 {