diff options
author | Eric Wong <e@80x24.org> | 2023-11-30 11:41:00 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-30 21:36:55 +0000 |
commit | ce30f3933fcb31cb0e7b6ac0956c1c8e64fedba3 (patch) | |
tree | 82fc38c5c888dd14a96055647836a4881dd10368 /lib/PublicInbox/Gcf2.pm | |
parent | f49f741ad77f0829492fe0b019255079a05f1f88 (diff) | |
download | public-inbox-ce30f3933fcb31cb0e7b6ac0956c1c8e64fedba3.tar.gz |
It saves some code in case we keep libgit2 around.
Diffstat (limited to 'lib/PublicInbox/Gcf2.pm')
-rw-r--r-- | lib/PublicInbox/Gcf2.pm | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Gcf2.pm index dcbb201d..78392990 100644 --- a/lib/PublicInbox/Gcf2.pm +++ b/lib/PublicInbox/Gcf2.pm @@ -9,7 +9,7 @@ use PublicInbox::Spawn qw(which run_qx); # may set PERL_INLINE_DIRECTORY use Fcntl qw(SEEK_SET); use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); use IO::Handle; # autoflush -use PublicInbox::Git; +use PublicInbox::Git qw($ck_unlinked_packs); use PublicInbox::Lock; use autodie qw(close open seek truncate); @@ -86,16 +86,6 @@ sub add_alt ($$) { 1; } -sub have_unlinked_files () { - # FIXME: port gcf2-like over to git.git so we won't need to - # deal with libgit2 - return 1 if $^O ne 'linux'; - if (my $s = PublicInbox::IO::try_cat("/proc/$$/maps")) { - return 1 if /\.(?:idx|pack) \(deleted\)/s; - } - undef; -} - # Usage: $^X -MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop [EXPIRE-TIMEOUT] # (see lib/PublicInbox/Gcf2Client.pm) sub loop (;$) { @@ -104,6 +94,7 @@ sub loop (;$) { my (%seen, $check_at); STDERR->autoflush(1); STDOUT->autoflush(1); + my $pid = $$; while (<STDIN>) { chomp; @@ -130,7 +121,8 @@ sub loop (;$) { $check_at //= $now + $exp; if ($now > $check_at) { undef $check_at; - if (have_unlinked_files()) { + if (!$ck_unlinked_packs || + $ck_unlinked_packs->($pid)) { $gcf2 = new(); %seen = (); } |