about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-11 02:48:18 +0000
committerEric Wong <e@80x24.org>2019-01-11 03:59:08 +0000
commit995849ed8a5a6f96105263a546e55e6c8811e76e (patch)
treeded7a289fd14ac3afd2b2dc927811144fd79df87 /lib/PublicInbox/V2Writable.pm
parent5126394a3806bd438bd0ef9c596ffa2e3cfb8db9 (diff)
downloadpublic-inbox-995849ed8a5a6f96105263a546e55e6c8811e76e.tar.gz
A stand-alone tool for purge will won't know the epoch
if nothing was ->add()-ed before.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index ec28e510..1f17fe21 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -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);