use Fcntl qw(LOCK_EX SEEK_SET);
use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
use IO::Handle; # autoflush
+use File::Path qw(make_path);
BEGIN {
my (%CFG, $c_src);
# PublicInbox::Spawn will set PERL_INLINE_DIRECTORY
# to ~/.cache/public-inbox/inline-c if it exists
my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} //
die 'PERL_INLINE_DIRECTORY not defined';
+ make_path($inline_dir);
my $f = "$inline_dir/.public-inbox.lock";
open my $fh, '+>', $f or die "open($f): $!";
}
sub add_alt ($$) {
- my ($gcf2, $objdir) = @_;
+ my ($gcf2, $git_dir) = @_;
+ my $objdir = PublicInbox::Git->new($git_dir)->git_path('objects');
# libgit2 (tested 0.27.7+dfsg.1-0.2 and 0.28.3+dfsg.1-1~bpo10+1
# in Debian) doesn't handle relative epochs properly when nested
while (<STDIN>) {
chomp;
my ($oid, $git_dir) = split(/ /, $_, 2);
- $seen{$git_dir} //= add_alt($gcf2, "$git_dir/objects");
+ $seen{$git_dir} //= add_alt($gcf2, $git_dir);
if (!$gcf2->cat_oid(1, $oid)) {
# retry once if missing. We only get unabbreviated OIDs
# from SQLite or Xapian DBs, here, so malicious clients
warn "I: $$ $oid missing, retrying in $git_dir\n";
$gcf2 = new();
- %seen = ($git_dir => add_alt($gcf2,"$git_dir/objects"));
+ %seen = ($git_dir => add_alt($gcf2, $git_dir);
$check_at = clock_gettime(CLOCK_MONOTONIC) + $exp;
if ($gcf2->cat_oid(1, $oid)) {
} else { # check expiry to deal with deleted pack files
my $now = clock_gettime(CLOCK_MONOTONIC);
$check_at //= $now + $exp;
- if ($now > $check_at && have_unlinked_files()) {
+ if ($now > $check_at) {
undef $check_at;
- $gcf2 = new();
- %seen = ();
+ if (have_unlinked_files()) {
+ $gcf2 = new();
+ %seen = ();
+ }
}
}
}