diff options
author | Eric Wong <e@80x24.org> | 2019-01-31 21:08:48 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-31 21:08:48 +0000 |
commit | 65323f060a3db731bb9fafa004336eeb4bbb8f00 (patch) | |
tree | ceaff52229c942314524f4bcac650e1db175c773 /lib/PublicInbox/V2Writable.pm | |
parent | ce4fe8f5144f7555ddd42b6a94ec602e042c6e43 (diff) | |
parent | 440b0feaa209e12e4bcb8ef16a95041fce71e7dc (diff) | |
download | public-inbox-65323f060a3db731bb9fafa004336eeb4bbb8f00.tar.gz |
* origin/purge: implement public-inbox-purge tool v2writable: read epoch on purge v2writable: cleanup processes when done v2writable: purge ignores non-existent git epoch directories v2writable: ->purge returns undef on no-op import: purge: reap fast-export process hoist out resolve_repo_dir from -index
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r-- | lib/PublicInbox/V2Writable.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 222df5c2..1f17fe21 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -285,10 +285,19 @@ sub purge_oids { $self->done; my $pfx = "$self->{-inbox}->{mainrepo}/git"; my $purges = []; - foreach my $i (0..$self->{epoch_max}) { - my $git = PublicInbox::Git->new("$pfx/$i.git"); + 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); my $im = $self->import_init($git, 0, 1); $purges->[$i] = $im->purge_oids($purge); + $im->done; } $purges; } @@ -390,7 +399,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; @@ -497,6 +506,7 @@ sub done { delete $self->{bnote}; $self->{transact_bytes} = 0; $self->lock_release if $parts; + $self->{-inbox}->git->cleanup; } sub git_init { |