Last active
June 22, 2016 20:35
-
-
Save niner/92a8e8e577ba4ebd00cac0af5e2bdbc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/CompUnit/Repository/Installation.pm b/src/core/CompUnit/Repository/Installation.pm | |
index 4a455bd..dfe76b9 100644 | |
--- a/src/core/CompUnit/Repository/Installation.pm | |
+++ b/src/core/CompUnit/Repository/Installation.pm | |
@@ -153,11 +153,10 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
my $precomp-dir = $.prefix.child('precomp'); | |
mkdir $precomp-dir unless $precomp-dir.e; | |
self!sources-dir; | |
- self!resources-dir; | |
- self!dist-dir; | |
+ my $resources-dir = self!resources-dir; | |
+ my $dist-dir = self!dist-dir; | |
self!bin-dir; | |
- if ($version < 2) { | |
- $.prefix.child('version').spurt('2'); | |
+ if ($version < 1) { | |
for $short-dir.dir -> $file { | |
my @ids = $file.lines.unique; | |
$file.unlink; | |
@@ -168,6 +167,18 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
} | |
} | |
} | |
+ if ($version < 2) { | |
+ for $dist-dir.dir -> $dist-file { | |
+ my %meta = Rakudo::Internals::JSON.from-json($dist-file.slurp); | |
+ my $files = %meta<files> //= []; | |
+ for eager $files.keys -> $file { | |
+ $files{"resources/$file"} = $files{$file}:delete | |
+ if $resources-dir.child($files{$file}).e; | |
+ } | |
+ $dist-file.spurt: Rakudo::Internals::JSON.to-json(%meta); | |
+ } | |
+ } | |
+ $.prefix.child('version').spurt('2'); | |
$!version = 2; | |
} | |
@@ -362,7 +373,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
my $lookup = $prefix.child('short').child(nqp::sha1($name)); | |
if $lookup.e { | |
my $repo-version = self!repository-version; | |
- my @dists = $repo-version < 2 | |
+ my @dists = $repo-version < 1 | |
?? $lookup.lines.unique.map({ | |
self!read-dist($_) | |
}) | |
@@ -371,7 +382,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
(id => $_.basename, ver => Version.new( $ver || 0 ), auth => $auth, api => $api).hash | |
}); | |
for @dists.grep({$_<auth> ~~ $auth and $_<ver> ~~ $ver}) -> $dist is copy { | |
- $dist = self!read-dist($dist<id>) if $repo-version >= 2; | |
+ $dist = self!read-dist($dist<id>) if $repo-version >= 1; | |
with $dist<files>{$file} { | |
my $candi = %$dist; | |
$candi<files>{$file} = self!resources-dir.child($candi<files>{$file}); | |
@@ -388,7 +399,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
my $lookup = $.prefix.child('short').child(nqp::sha1($spec.short-name)); | |
if $lookup.e { | |
my @dists = ( | |
- $repo-version < 2 | |
+ $repo-version < 1 | |
?? $lookup.lines.unique.map({ | |
$_ => self!read-dist($_) | |
}) | |
@@ -401,7 +412,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
and $_.value<ver> ~~ $spec.version-matcher | |
}); | |
for @dists.sort(*.value<ver>).reverse.map(*.kv) -> ($dist-id, $dist) { | |
- return ($dist-id, $repo-version < 2 ?? $dist !! self!read-dist($dist-id)); | |
+ return ($dist-id, $repo-version < 1 ?? $dist !! self!read-dist($dist-id)); | |
} | |
} | |
} | |
@@ -482,7 +493,8 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) { | |
method resource($dist-id, $key) { | |
my $dist = Rakudo::Internals::JSON.from-json(self!dist-dir.child($dist-id).slurp); | |
- self!resources-dir.child($dist<files>{$key}) | |
+ # need to strip the leading resources/ on old repositories | |
+ self!resources-dir.child($dist<files>{$key.substr(self!repository-version < 2 ?? 10 !! 0)}) | |
} | |
method id() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment