X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiMirror.pm;h=ec2b56dfeb89331c647e9ca35c4c53798d4a2d35;hb=7b654d175cf2e31b4354929ea678563f534947e5;hp=34a4bd1cb2ea5cc8d68beda701d62c37843b1d75;hpb=68e182a29404407680bee482f99ee24dd9c3c7cb;p=public-inbox.git diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 34a4bd1c..ec2b56df 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -18,7 +18,7 @@ use PublicInbox::Config; use PublicInbox::Inbox; use PublicInbox::LeiCurl; use PublicInbox::OnDestroy; -use Digest::SHA qw(sha256_hex sha1_hex); +use PublicInbox::SHA qw(sha256_hex sha1_hex); use POSIX qw(strftime); our $LIVE; # pid => callback @@ -31,9 +31,8 @@ sub keep_going ($) { $_[0]->{lei}->{opt}->{'keep-going'}); } -sub _wq_done_wait { # dwaitpid callback (via wq_eof) - my ($arg, $pid) = @_; - my ($mrr, $lei) = @$arg; +sub _wq_done_wait { # awaitpid cb (via wq_eof) + my ($pid, $mrr, $lei) = @_; if ($?) { $lei->child_error($?); } elsif (!$lei->{child_error}) { @@ -236,7 +235,7 @@ sub index_cloned_inbox { my ($k) = ($sw =~ /\A([\w-]+)/); $opt->{$k} = $lei->{opt}->{$k}; } - # force synchronous dwaitpid for v2: + # force synchronous awaitpid for v2: local $PublicInbox::DS::in_loop = 0; my $cfg = PublicInbox::Config->new(undef, $lei->{2}); my $env = PublicInbox::Admin::index_prepare($opt, $cfg); @@ -516,6 +515,7 @@ sub resume_fetch { fetch_args($self->{lei}, $opt), $rn ]; push @$cmd, '-P' if $self->{lei}->{prune}; # --prune-tags implied my $run_puh = PublicInbox::OnDestroy->new($$, \&run_puh, $self, $fini); + ++$self->{chg}->{nr_chg}; start_cmd($self, $cmd, $opt, $run_puh); } @@ -533,6 +533,7 @@ sub fgrp_enqueue { $fgrp->{dry_run} ? $fgrp->{lei}->qerr("# @cmd @kv") : run_die([@cmd, @kv], undef, $opt); } + ++$fgrp->{chg}->{nr_chg}; push @{$FGRP_TODO->{$fgrp->{-osdir}}}, $fgrp; } @@ -565,6 +566,7 @@ sub clone_v1 { "$self->{dst}$ref"; } } + ++$self->{chg}->{nr_chg}; start_cmd($self, $cmd, $opt, PublicInbox::OnDestroy->new($$, \&run_puh, $self, $fini)); } @@ -750,6 +752,7 @@ sub update_ent { } } symlink($tgt, $ln) or die "symlink($tgt, $ln): $!"; + ++$self->{chg}->{nr_chg}; } } if (defined(my $t = $self->{-ent}->{modified})) { @@ -1051,7 +1054,9 @@ EOM warn "\t", $_, "\n" for @local; my (undef, $dn, $bn) = File::Spec->splitpath($f); - atomic_write($dn, $bn, join("\n", @list, '')); + $self->{chg}->{nr_chg} += scalar(@remote) + scalar(@local); + my $new = join("\n", @list, ''); + atomic_write($dn, $bn, $new) if $new ne $old; } # FIXME: this gets confused by single inbox instance w/ global manifest.js.gz @@ -1082,7 +1087,10 @@ sub try_manifest { } # bail out if curl -z/--timecond hit 304 Not Modified, $ft will be empty - return $lei->qerr("# $manifest unchanged") if -f $manifest && !-s $ft; + if (-f $manifest && !-s $ft) { + $lei->child_error(127 << 8) if $lei->{opt}->{'exit-code'}; + return $lei->qerr("# $manifest unchanged"); + } my $m = eval { decode_manifest($ft, $ft, $uri) }; if ($@) { @@ -1170,6 +1178,8 @@ W: The following exist and have not been converted to symlinks EOM dump_project_list($self, $m); ft_rename($ft, $manifest, 0666); + !$self->{chg}->{nr_chg} && $lei->{opt}->{'exit-code'} and + $lei->child_error(127 << 8); } sub start_clone_url {