]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: read epoch on purge
authorEric Wong <e@80x24.org>
Fri, 11 Jan 2019 02:48:18 +0000 (02:48 +0000)
committerEric Wong <e@80x24.org>
Fri, 11 Jan 2019 03:59:08 +0000 (03:59 +0000)
A stand-alone tool for purge will won't know the epoch
if nothing was ->add()-ed before.

lib/PublicInbox/V2Writable.pm

index ec28e510706d92c836dd48bbff8fbd4d3179fc94..1f17fe212943a51af9b89071f28b07cd7ef74580 100644 (file)
@@ -285,7 +285,13 @@ sub purge_oids {
        $self->done;
        my $pfx = "$self->{-inbox}->{mainrepo}/git";
        my $purges = [];
-       foreach my $i (0..$self->{epoch_max}) {
+       my $max = $self->{epoch_max};
+
+       unless (defined($max)) {
+               defined(my $latest = git_dir_latest($self, \$max)) or return;
+               $self->{epoch_max} = $max;
+       }
+       foreach my $i (0..$max) {
                my $git_dir = "$pfx/$i.git";
                -d $git_dir or next;
                my $git = PublicInbox::Git->new($git_dir);