diff options
author | Eric Wong <e@80x24.org> | 2021-09-24 10:56:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-24 23:22:08 +0000 |
commit | 718d054be8b2cc23635b42e8ce880424492d3a84 (patch) | |
tree | a545f92696606c950e5fd86f930d2c9b578d2859 /t | |
parent | 3596019278ef489f27e0659c752977f60f847903 (diff) | |
download | public-inbox-718d054be8b2cc23635b42e8ce880424492d3a84.tar.gz |
This makes it easier for users to enable fetching on a previously read-only epoch. Prior to this change, users were required to delete manifest.js.gz in addition to adding the writable bit. Now, they just have to "chmod +w $EPOCH_DIR".
Diffstat (limited to 't')
-rw-r--r-- | t/v2mirror.t | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/v2mirror.t b/t/v2mirror.t index 1231b72d..fa4a717d 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -9,6 +9,7 @@ use PublicInbox::Spawn qw(which); require_git(2.6); require_cmd('curl'); local $ENV{HOME} = abs_path('t'); +use IO::Uncompress::Gunzip qw(gunzip $GunzipError); # Integration tests for HTTP cloning + mirroring require_mods(qw(Plack::Util Plack::Builder @@ -288,6 +289,29 @@ if ('test read-only epoch dirs') { is_deeply(\@g2, \@g, 'cloned again'); is(scalar(grep { -w $_ } @g2), scalar(@w) + 1, 'got one more cloned epoch'); + + # make 0.git writable and fetch into it, relies on culled manifest + chmod(0755, $g2[0]) or xbail "chmod: $!"; + my @before = glob("$g2[0]/objects/*/*"); + run_script([qw(-fetch -q)], undef, { -C => $dst }); + is($?, 0, 'no error from partial fetch'); + my @after = glob("$g2[0]/objects/*/*"); + ok(scalar(@before) < scalar(@after), 'fetched after chmod 0755 0.git'); + + # ensure culled manifest is maintained after fetch + gunzip("$dst/manifest.js.gz" => \(my $m), MultiStream => 1) or + xbail "gunzip: $GunzipError"; + $m = PublicInbox::Config->json->decode($m); + for my $k (keys %$m) { # /$name/git/$N.git + my ($nr) = ($k =~ m!/git/([0-9]+)\.git\z!); + ok(-w "$dst/git/$nr.git", "writable $nr.git in manifest"); + } + for my $ro (grep { !-w $_ } @g2) { + my ($nr) = ($ro =~ m!/git/([0-9]+)\.git\z!); + is(grep(m!/git/$nr\.git\z!, keys %$m), 0, + "read-only $nr.git not in manifest") + or xbail([sort keys %$m]); + } } my $err = ''; |