#!perl -w
-# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
--ng NEWSGROUP set NNTP newsgroup name
--skip-artnum=NUM NNTP article numbers to skip
--skip-epoch=NUM epochs to skip (-V2 only)
- -J JOBS number of indexing jobs (-V2 only), (default: 4)
+ -j JOBS number of indexing jobs (-V2 only), (default: 4)
See public-inbox-init(1) man page for full documentation.
EOF
# git-config will operate on this (and rename on success):
require File::Temp;
-my $fh = File::Temp->new(TEMPLATE => 'pi-init-XXXXXXXX', DIR => $dir);
+my $fh = File::Temp->new(TEMPLATE => 'pi-init-XXXX', DIR => $dir);
# Now, we grab another lock to use git-config(1) locking, so it won't
# wait on the lock, unlike some of our internal flock()-based locks.
warn "could not open config file: $lockfile: $!\n";
exit(255);
};
-my $auto_unlink = UnlinkMe->new($lockfile);
+require PublicInbox::OnDestroy;
+my $auto_unlink = PublicInbox::OnDestroy->new($$, sub { unlink $lockfile });
my ($perm, %seen);
if (-e $pi_config) {
open(my $oh, '<', $pi_config) or die "unable to read $pi_config: $!\n";
rename $pi_config_tmp, $pi_config or
die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
-$auto_unlink->DESTROY;
-
-package UnlinkMe;
-use strict;
-
-sub new {
- my ($klass, $file) = @_;
- bless { file => $file }, $klass;
-}
-
-sub DESTROY {
- my $f = delete($_[0]->{file});
- unlink($f) if defined($f);
-}
-1;
+undef $auto_unlink; # trigger ->DESTROY