diff options
author | Eric Wong <e@80x24.org> | 2019-01-31 00:32:42 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-31 00:32:42 +0000 |
commit | 2d4403cf9972f8ae78aa52fe6ce7a01d9b6757c1 (patch) | |
tree | 4bc738af91593e725f5f5088cc3f8c3a446fd695 /lib/PublicInbox/Inbox.pm | |
parent | 3041de7ee07ca13d3d8465aa68f076269e19fc3b (diff) | |
download | public-inbox-2d4403cf9972f8ae78aa52fe6ce7a01d9b6757c1.tar.gz |
Otherwise, long-running but idle git processes may keep unlinked packs around indefinitely and waste disk space.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index d57e46d2..6fe896f4 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -22,12 +22,25 @@ my $cleanup_broken = $@; my $CLEANUP = {}; # string(inbox) -> inbox sub cleanup_task () { $cleanup_timer = undef; + my $next = {}; for my $ibx (values %$CLEANUP) { - foreach my $f (qw(git mm search)) { + my $again; + foreach my $f (qw(mm search)) { delete $ibx->{$f} if SvREFCNT($ibx->{$f}) == 1; } + my $expire = time - 60; + if (my $git = $ibx->{git}) { + $again = $git->cleanup($expire); + } + if (my $gits = $ibx->{-repo_objs}) { + foreach my $git (@$gits) { + $again = 1 if $git->cleanup($expire); + } + } + $again ||= !!($ibx->{mm} || $ibx->{search}); + $next->{"$ibx"} = $ibx if $again; } - $CLEANUP = {}; + $CLEANUP = $next; } sub _cleanup_later ($) { |