|
6 | 6 |
|
7 | 7 | """ |
8 | 8 | manifest(c::Pkg.Types.Context) |
9 | | -Retrieves the manifest of a Context. |
| 9 | +Retrieves the UUID -> PackageEntry map from the manifest of a Context. |
10 | 10 | """ |
11 | | -manifest(c::Pkg.Types.Context) = c.env.manifest |
| 11 | +function manifest(c::Pkg.Types.Context) |
| 12 | + m = c.env.manifest |
| 13 | + if VERSION < v"1.6.2" |
| 14 | + return m |
| 15 | + else |
| 16 | + return m.deps |
| 17 | + end |
| 18 | +end |
| 19 | + |
| 20 | +""" |
| 21 | + read_manifest(manifest_filename) |
| 22 | +
|
| 23 | +Read the manifest from the path and return the UUID -> PackageEntry map. |
| 24 | +If the file can't be read, return `nothing`. |
| 25 | +""" |
| 26 | +function read_manifest(manifest_filename) |
| 27 | + try |
| 28 | + m = Pkg.API.read_manifest(manifest_filename) |
| 29 | + if VERSION < v"1.6.2" |
| 30 | + return m |
| 31 | + else |
| 32 | + return m.deps |
| 33 | + end |
| 34 | + catch err |
| 35 | + if err isa Pkg.Types.PkgError |
| 36 | + @warn "Could not load manifest." |
| 37 | + return nothing |
| 38 | + else |
| 39 | + rethrow(err) |
| 40 | + end |
| 41 | + end |
| 42 | +end |
12 | 43 |
|
13 | 44 | """ |
14 | 45 | project(c::Pkg.Types.Context) |
@@ -49,7 +80,7 @@ function isinmanifest end |
49 | 80 |
|
50 | 81 | packagename(pkg::Pair{String,Any})::String = first(pkg) |
51 | 82 | function packagename(c::Pkg.Types.Context, uuid) |
52 | | - for (n, p) in c.env.manifest |
| 83 | + for (n, p) in manifest(c) |
53 | 84 | if get(first(p), "uuid", "") == string(uuid) |
54 | 85 | return n |
55 | 86 | end |
@@ -79,8 +110,8 @@ function isinmanifest end |
79 | 110 | version(pe::PackageEntry) = get(pe[1], "version", nothing) |
80 | 111 | tree_hash(pe) = get(pe[1], "git-tree-sha1", nothing) |
81 | 112 |
|
82 | | - frommanifest(c::Pkg.Types.Context, uuid) = frommanifest(c.env.manifest, uuid) |
83 | | - |
| 113 | + frommanifest(c::Pkg.Types.Context, uuid) = frommanifest(manifest(c), uuid) |
| 114 | + |
84 | 115 | function frommanifest(manifest::Dict{String,Any}, uuid) |
85 | 116 | for p in values(manifest) |
86 | 117 | if get(first(p), "uuid", "") == string(uuid) |
|
548 | 579 |
|
549 | 580 | function write_cache(uuid, pkg::Package, ctx, storedir) |
550 | 581 | isinmanifest(ctx, uuid) || return "" |
551 | | - cache_paths = get_cache_path(ctx.env.manifest, uuid) |
| 582 | + cache_paths = get_cache_path(manifest(ctx), uuid) |
552 | 583 | !isdir(joinpath(storedir, cache_paths[1])) && mkdir(joinpath(storedir, cache_paths[1])) |
553 | 584 | !isdir(joinpath(storedir, cache_paths[1], cache_paths[2])) && mkdir(joinpath(storedir, cache_paths[1], cache_paths[2])) |
554 | 585 | @info "Now writing to disc $uuid" |
|
0 commit comments