Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/SymbolServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
if download
manifest_filename = isfile(joinpath(environment_path, "JuliaManifest.toml")) ? joinpath(environment_path, "JuliaManifest.toml") : joinpath(environment_path, "Manifest.toml")
if isfile(manifest_filename)
let manifest = Pkg.Types.read_manifest(manifest_filename)
let manifest = read_manifest(manifest_filename); if manifest !== nothing
asyncmap(collect(validate_disc_store(ssi.store_path, manifest)), ntasks = 10) do pkg
uuid = packageuuid(pkg)
get_file_from_cloud(manifest, uuid, environment_path, ssi.depot_path, ssi.store_path, ssi.store_path)
end
end end
end
end
end
Expand Down Expand Up @@ -144,16 +144,8 @@ function load_project_packages_into_store!(ssi::SymbolServerInstance, environmen
end

manifest_filename = isfile(joinpath(environment_path, "JuliaManifest.toml")) ? joinpath(environment_path, "JuliaManifest.toml") : joinpath(environment_path, "Manifest.toml")
manifest = try
Pkg.API.read_manifest(manifest_filename)
catch err
if err isa Pkg.Types.PkgError
@warn "Could not load manifest."
return
else
rethrow(err)
end
end
manifest = read_manifest(manifest_filename)
manifest === nothing && return

for uuid in values(deps(project))
load_package_from_cache_into_store!(ssi, uuid, manifest, store)
Expand Down
4 changes: 2 additions & 2 deletions src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ for (pk_name, uuid) in toplevel_pkgs
cache_path = joinpath(server.storedir, SymbolServer.get_cache_path(manifest(ctx), uuid)...)

if isfile(cache_path)
if is_package_deved(ctx.env.manifest, uuid)
if is_package_deved(manifest(ctx), uuid)
try
cached_version = open(cache_path) do io
CacheStore.read(io)
end
if sha_pkg(frommanifest(ctx.env.manifest, uuid)) != cached_version.sha
if sha_pkg(frommanifest(manifest(ctx), uuid)) != cached_version.sha
@info "Outdated sha, will recache package $pk_name ($uuid)"
push!(packages_to_load, uuid)
else
Expand Down
43 changes: 37 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,40 @@ end

"""
manifest(c::Pkg.Types.Context)
Retrieves the manifest of a Context.
Retrieves the UUID -> PackageEntry map from the manifest of a Context.
"""
manifest(c::Pkg.Types.Context) = c.env.manifest
function manifest(c::Pkg.Types.Context)
m = c.env.manifest
if VERSION < v"1.6.2"
return m
else
return m.deps
end
end

"""
read_manifest(manifest_filename)

Read the manifest from the path and return the UUID -> PackageEntry map.
If the file can't be read, return `nothing`.
"""
function read_manifest(manifest_filename)
try
m = Pkg.API.read_manifest(manifest_filename)
if VERSION < v"1.6.2"
return m
else
return m.deps
end
catch err
if err isa Pkg.Types.PkgError
@warn "Could not load manifest."
return nothing
else
rethrow(err)
end
end
end

"""
project(c::Pkg.Types.Context)
Expand Down Expand Up @@ -49,7 +80,7 @@ function isinmanifest end

packagename(pkg::Pair{String,Any})::String = first(pkg)
function packagename(c::Pkg.Types.Context, uuid)
for (n, p) in c.env.manifest
for (n, p) in manifest(c)
if get(first(p), "uuid", "") == string(uuid)
return n
end
Expand Down Expand Up @@ -79,8 +110,8 @@ function isinmanifest end
version(pe::PackageEntry) = get(pe[1], "version", nothing)
tree_hash(pe) = get(pe[1], "git-tree-sha1", nothing)

frommanifest(c::Pkg.Types.Context, uuid) = frommanifest(c.env.manifest, uuid)
frommanifest(c::Pkg.Types.Context, uuid) = frommanifest(manifest(c), uuid)

function frommanifest(manifest::Dict{String,Any}, uuid)
for p in values(manifest)
if get(first(p), "uuid", "") == string(uuid)
Expand Down Expand Up @@ -548,7 +579,7 @@ end

function write_cache(uuid, pkg::Package, ctx, storedir)
isinmanifest(ctx, uuid) || return ""
cache_paths = get_cache_path(ctx.env.manifest, uuid)
cache_paths = get_cache_path(manifest(ctx), uuid)
!isdir(joinpath(storedir, cache_paths[1])) && mkdir(joinpath(storedir, cache_paths[1]))
!isdir(joinpath(storedir, cache_paths[1], cache_paths[2])) && mkdir(joinpath(storedir, cache_paths[1], cache_paths[2]))
@info "Now writing to disc $uuid"
Expand Down