From 995849ed8a5a6f96105263a546e55e6c8811e76e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 11 Jan 2019 02:48:18 +0000 Subject: v2writable: read epoch on purge A stand-alone tool for purge will won't know the epoch if nothing was ->add()-ed before. --- lib/PublicInbox/V2Writable.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/V2Writable.pm') 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); -- cgit v1.2.3-24-ge0c7