Skip to content

Commit b4a8014

Browse files
authored
Merge pull request #2353 from ianshmean/ib/recursive_dep_size_backport16
[release-1.6] backports
2 parents cb090a1 + 14eeb39 commit b4a8014

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

src/API.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,19 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(7), verbose=false,
769769

770770
function recursive_dir_size(path)
771771
size = 0
772-
for (root, dirs, files) in walkdir(path)
773-
for file in files
774-
path = joinpath(root, file)
775-
try
776-
size += lstat(path).size
777-
catch
778-
@warn "Failed to calculate size of $path"
772+
try
773+
for (root, dirs, files) in walkdir(path)
774+
for file in files
775+
path = joinpath(root, file)
776+
try
777+
size += lstat(path).size
778+
catch ex
779+
@error("Failed to calculate size of $path", exception=ex)
780+
end
779781
end
780782
end
783+
catch ex
784+
@error("Failed to calculate size of $path", exception=ex)
781785
end
782786
return size
783787
end
@@ -1292,9 +1296,7 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
12921296
" Otherwise, remove `$name` with `Pkg.rm(\"$name\")`.",
12931297
" Finally, run `Pkg.instantiate()` again.")
12941298
end
1295-
# TODO: seems to be a bug in is_instantiated on the line below so we have to download
1296-
# artifacts here even though we do the same at the end of this function
1297-
Operations.download_artifacts(ctx, [dirname(ctx.env.manifest_file)]; platform=platform, verbose=verbose)
1299+
12981300
# check if all source code and artifacts are downloaded to exit early
12991301
if Operations.is_instantiated(ctx)
13001302
allow_autoprecomp && Pkg._auto_precompile(ctx)
@@ -1347,10 +1349,14 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
13471349

13481350
# Install all packages
13491351
new_apply = Operations.download_source(ctx, pkgs)
1350-
# Install all artifacts
1351-
Operations.download_artifacts(ctx, pkgs; platform=platform, verbose=verbose)
1352+
# Install artifacts for deps and artifacts for current package, if applicable
1353+
art_pkgs = copy(pkgs)
1354+
if ctx.env.pkg !== nothing
1355+
push!(art_pkgs, ctx.env.pkg)
1356+
end
1357+
Operations.download_artifacts(ctx, art_pkgs; platform, verbose)
13521358
# Run build scripts
1353-
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose=verbose)
1359+
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)
13541360

13551361
allow_autoprecomp && Pkg._auto_precompile(ctx; kwargs...)
13561362
end

src/Operations.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ end
114114
function is_instantiated(ctx::Context)::Bool
115115
# Load everything
116116
pkgs = load_all_deps(ctx)
117-
# Make sure all paths exist
117+
# If the top-level project is a package, ensure it is instantiated as well
118+
if ctx.env.pkg !== nothing
119+
push!(pkgs, Types.PackageSpec(
120+
name=ctx.env.pkg.name, uuid=ctx.env.pkg.uuid, version=ctx.env.pkg.version, path=dirname(ctx.env.project_file)
121+
))
122+
end
123+
# Make sure all paths/artifacts exist
118124
return all(pkg -> is_package_downloaded(ctx, pkg), pkgs)
119125
end
120126

src/Types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ function EnvCache(env::Union{Nothing,String}=nothing)
270270
name = project.name,
271271
uuid = project.uuid,
272272
version = something(project.version, VersionNumber("0.0")),
273+
path = project_dir,
273274
)
274275
else
275276
project_package = nothing

0 commit comments

Comments
 (0)