]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei import: avoid IMAPTracker, use LeiMailSync more
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 7ffcf163182cb16d7628c9e95aaa43649bb1a20c..52ce8ec272e74e68d3ba7b5beabb566240d01066 100644 (file)
@@ -211,7 +211,7 @@ our %CMD = ( # sorted in order of importance/use:
 'import' => [ 'LOCATION...|--stdin',
        'one-time import/update from URL or filesystem',
        qw(stdin| offset=i recursive|r exclude=s include|I=s
-       lock=s@ in-format|F=s kw! verbose|v+ incremental! sync!), @c_opt ],
+       lock=s@ in-format|F=s kw! verbose|v+ incremental! mail-sync!), @c_opt ],
 'convert' => [ 'LOCATION...|--stdin',
        'one-time conversion from URL or filesystem to another format',
        qw(stdin| in-format|F=s out-format|f=s output|mfolder|o=s
@@ -487,19 +487,14 @@ sub _lei_atfork_child {
        # we need to explicitly close things which are on stack
        if ($persist) {
                chdir '/' or die "chdir(/): $!";
-               my @io = delete @$self{qw(0 1 2 sock)};
-               unless ($self->{oneshot}) {
-                       close($_) for @io;
-               }
+               close($_) for (grep(defined, delete @$self{qw(0 1 2 sock)}));
                if (my $cfg = $self->{cfg}) {
                        delete $cfg->{-lei_store};
                }
        } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly
                open STDERR, '+>&='.fileno($self->{2}) or warn "open $!";
        }
-       for (delete @$self{qw(3 old_1 au_done)}) {
-               close($_) if defined($_);
-       }
+       close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)}));
        if (my $op_c = delete $self->{pkt_op_c}) {
                close(delete $op_c->{sock});
        }
@@ -1213,13 +1208,8 @@ sub oneshot {
        local $quit = $exit if $exit;
        local %PATH2CFG;
        umask(077) // die("umask(077): $!");
-       my $self = bless {
-               oneshot => 1,
-               0 => *STDIN{GLOB},
-               1 => *STDOUT{GLOB},
-               2 => *STDERR{GLOB},
-               env => \%ENV
-       }, __PACKAGE__;
+       my $self = bless { oneshot => 1, env => \%ENV }, __PACKAGE__;
+       for (0..2) { open($self->{$_}, '+<&=', $_) or die "open fd=$_: $!" }
        dispatch($self, @ARGV);
        x_it($self, $self->{child_error}) if $self->{child_error};
 }