Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid writing and reparsing the artifact usage file once per artifact file in the project deps #4117

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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)]
martinholters marked this conversation as resolved.
Show resolved Hide resolved
end

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