]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: allow --epoch on mixed v1/v2 clones
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:24 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:54 +0000 (23:38 +0000)
It's entirely possible an instance will have both v1 and v2
inboxes (or v2 inboxes and coderepos).  Don't punish --epoch
users by forcing them to run multiple commands.

lib/PublicInbox/LeiMirror.pm

index 0a93ed440c868e73d375bd65cbc09c958bec2367..ddb1e74794102761beb7f5a9f65757f0123ba550 100644 (file)
@@ -579,7 +579,8 @@ sub try_manifest {
        }
        my ($path_pfx, $n, $multi) = multi_inbox($self, \$path, $m);
        return $lei->child_error(1, $multi) if !ref($multi);
-       if (my $v2 = delete $multi->{v2}) {
+       my $v2 = delete $multi->{v2};
+       if ($v2) {
                for my $name (sort keys %$v2) {
                        my $epochs = delete $v2->{$name};
                        my %v2_epochs = map {
@@ -605,6 +606,7 @@ EOM
                }
        }
        if (my $v1 = delete $multi->{v1}) {
+               delete local $lei->{opt}->{epoch} if defined($v2);
                my $p = $path_pfx.$path;
                chop($p) if substr($p, -1, 1) eq '/';
                $uri->path($p);