Skip to content

Commit

Permalink
avoid writing and reparsing the artifact usage file once per artifact…
Browse files Browse the repository at this point in the history
… file in the project deps (#4117)
  • Loading branch information
KristofferC authored Dec 17, 2024
1 parent a1cfc6d commit b995782
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,8 @@ function download_artifacts(ctx::Context;
end
end

for f in used_artifact_tomls
write_env_usage(f, "artifact_usage.toml")
end

write_env_usage(used_artifact_tomls, "artifact_usage.toml")
end

function check_artifacts_downloaded(pkg_root::String; platform::AbstractPlatform=HostPlatform())
Expand Down
13 changes: 10 additions & 3 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,14 @@ function workspace_resolve_hash(env::EnvCache)
return bytes2hex(sha1(str))
end

function write_env_usage(source_file::AbstractString, usage_filepath::AbstractString)

write_env_usage(source_file::AbstractString, usage_filepath::AbstractString) =
write_env_usage([source_file], usage_filepath)

function write_env_usage(source_files, usage_filepath::AbstractString)
# Don't record ghost usage
!isfile(source_file) && return
source_files = filter(isfile, source_files)
isempty(source_files) && return

# Ensure that log dir exists
!ispath(logdir()) && mkpath(logdir())
Expand All @@ -630,7 +635,9 @@ function write_env_usage(source_file::AbstractString, usage_filepath::AbstractSt
end

# record new usage
usage[source_file] = [Dict("time" => timestamp)]
for source_file in source_files
usage[source_file] = [Dict("time" => timestamp)]
end

# keep only latest usage info
for k in keys(usage)
Expand Down

0 comments on commit b995782

Please sign in to comment.