]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-index
index: avoid false-positive warning on off-by-one
[public-inbox.git] / script / public-inbox-index
index 73f88ac6bee72fd0eabc3497881cf42e3392cc97..e487e3fe327f69080e29996bb934a3cd219f46f8 100755 (executable)
@@ -31,7 +31,7 @@ my %opts = (
        '--prune' => \$prune,
 );
 GetOptions(%opts) or die "bad command-line args\n$usage";
-die "--jobs must be positive\n" if defined $jobs && $jobs <= 0;
+die "--jobs must be positive\n" if defined $jobs && $jobs < 0;
 
 my @dirs;
 
@@ -101,15 +101,15 @@ sub index_dir {
                eval { require PublicInbox::V2Writable };
                die "v2 requirements not met: $@\n" if $@;
                my $v2w = eval {
-                       local $ENV{NPROC} = $jobs;
+                       $jobs and local $ENV{NPROC} = $jobs;
                        PublicInbox::V2Writable->new($repo);
                };
                if (defined $jobs) {
-                       if ($jobs == 1) {
+                       if ($jobs == 0) {
                                $v2w->{parallel} = 0;
                        } else {
                                my $n = $v2w->{partitions};
-                               if ($jobs != $n) {
+                               if ($jobs != ($n + 1)) {
                                        warn
 "Unable to respect --jobs=$jobs, inbox was created with $n partitions\n";
                                }