X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiMirror.pm;h=d6d2c69eb90e981b57eeafbf7f8f8bf7576c769d;hb=40df0363872f9b34556703221c12bb36ece714d8;hp=d4b146997c368876298d83f03f59e39aefa385a8;hpb=556fb7af0e43c1183933d6afe451eb81296b802c;p=public-inbox.git diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index d4b14699..d6d2c69e 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -428,20 +428,9 @@ sub forkgroup_prep { my $key = $self->{-key} // die 'BUG: no -key'; my $rn = substr(sha256_hex($key), 0, 16); if (!-d $self->{cur_dst} && !$self->{dry_run}) { - my $alt = File::Spec->rel2abs("$dir/objects"); PublicInbox::Import::init_bare($self->{cur_dst}); - my $o = "$self->{cur_dst}/objects"; - my $f = "$o/info/alternates"; - my $l = File::Spec->abs2rel($alt, File::Spec->rel2abs($o)); - open my $fh, '+>>', $f or die "open($f): $!"; - seek($fh, SEEK_SET, 0) or die "seek($f): $!"; - chomp(my @cur = <$fh>); - if (!grep(/\A\Q$l\E\z/, @cur)) { - say $fh $l or die "say($f): $!"; - } - close $fh or die "close($f): $!"; - $f = "$self->{cur_dst}/config"; - open $fh, '+>>', $f or die "open:($f): $!"; + my $f = "$self->{cur_dst}/config"; + open my $fh, '+>>', $f or die "open:($f): $!"; print $fh <{dry_run}) { + my $alt = File::Spec->rel2abs("$dir/objects"); + my $o = "$self->{cur_dst}/objects"; + my $f = "$o/info/alternates"; + my $l = File::Spec->abs2rel($alt, File::Spec->rel2abs($o)); + open my $fh, '+>>', $f or die "open($f): $!"; + seek($fh, SEEK_SET, 0) or die "seek($f): $!"; + chomp(my @cur = <$fh>); + if (!grep(/\A\Q$l\E\z/, @cur)) { + say $fh $l or die "say($f): $!"; + } + close $fh or die "close($f): $!"; + } bless { %$self, -osdir => $dir, -remote => $rn, -uri => $uri }, __PACKAGE__; @@ -705,6 +707,7 @@ sub update_ent { } if (my $symlinks = $self->{-ent}->{symlinks}) { my $top = File::Spec->rel2abs($self->{dst}); + push @{$self->{-new_symlinks}}, @$symlinks; for my $p (@$symlinks) { my $ln = "$top/$p"; $ln =~ tr!/!/!s; @@ -1005,6 +1008,8 @@ sub dump_project_list ($$) { $new{substr($_, 1)} = 1 for keys %$m; # drop leading '/' my @list = sort keys %new; my @remote = grep { !defined($new{$_}) } @list; + my %lnk = map { substr($_, 1) => undef } @{$self->{-new_symlinks}}; + @remote = grep { !exists($lnk{$_}) } @remote; warn <{src}: @@ -1056,6 +1061,7 @@ sub try_manifest { } local $self->{chg} = {}; local $self->{-local_manifest} = load_current_manifest($self); + local $self->{-new_symlinks} = []; my ($path_pfx, $n, $multi) = multi_inbox($self, \$path, $m); return $lei->child_error(1, $multi) if !ref($multi); my $v2 = delete $multi->{v2};