]> Sergey Matveev's repositories - public-inbox.git/commitdiff
import_slrnspool: load private config key
authorEric Wong <e@80x24.org>
Sun, 11 Jan 2015 23:58:55 +0000 (23:58 +0000)
committerEric Wong <e@80x24.org>
Sun, 11 Jan 2015 23:58:55 +0000 (23:58 +0000)
PublicInbox::Config->lookup won't return unknown keys

scripts/import_slrnspool

index d95836d69c6a8937a9a97bd20d645a05c0c6650f..e55c96c7dcde95b376db44f5934bf96fe4d22286 100755 (executable)
@@ -31,16 +31,28 @@ if ($ENV{'FILTER'}) {
        @mda = (qw(ssoma-mda -1), $cfg->{mainrepo});
 }
 
-sub get_min {
+sub key {
        my ($cfg) = @_;
-       $cfg->{importslrnspoolstate} || 0;
+       "publicinbox.$cfg->{listname}.importslrnspoolstate";
+}
+
+sub get_min {
+       my $f = PublicInbox::Config->default_file;
+       my @cmd = (qw/git config/, "--file=$f", key($cfg));
+       use IPC::Run qw/run/;
+
+       my $in = '';
+       my $out = '';
+       unless (run(\@cmd, \$in, \$out)) {
+               $out = 0;
+       }
+       int($out);
 }
 
 sub set_min {
        my ($cfg, $num) = @_;
        my $f = PublicInbox::Config->default_file;
-       my @cmd = (qw/git config/, "--file=$f",
-                  "publicinbox.$cfg->{listname}.importslrnspoolstate", $num);
+       my @cmd = (qw/git config/, "--file=$f", key($cfg), $num);
        system(@cmd) == 0 or die join(' ', @cmd). " failed: $?\n";
 }