Repository: JuliaLang/julia
File: stdlib/Artifacts/src/Artifacts.jl (Julia)

Code before:

        # Move up a directory
        path = dirname(path)
    end

    # We never found anything, just return `nothing`
    return nothing
end

# We do this to avoid doing the `joinpath()` work if we don't have to, and also to
# avoid a trailing slash due to `joinpath()`'s habit of including one when the last
# argument is the empty string.
function jointail(dir, tail)
    if !isempty(tail)
        return joinpath(dir, tail)
    else
        return dir
    end
end

function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
    world = Base._require_world_age[]
    if world == typemax(UInt)
        world = Base.get_world_counter()
    end
    return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))
end

function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
    pkg = Base.PkgId(__module__)
    if pkg.uuid !== nothing
        # Process overrides for this UUID, if we know what it is
        process_overrides(artifact_dict, pkg.uuid)
    end

    # If the artifact exists, we're in the happy path and we can immediately
    # return the path to the artifact:
    dirs = artifact_paths(hash; honor_overrides=true)
    for dir in dirs
        if isdir(dir)
            return jointail(dir, path_tail)
        end
    end

    # If not, try determining what went wrong:
    meta = artifact_meta(name, artifact_dict, artifacts_toml; platform)
    if meta !== nothing && get(meta, "lazy", false)
        if LazyArtifacts isa Module && isdefined(LazyArtifacts, :ensure_artifact_installed)
            if nameof(LazyArtifacts) in (:Pkg, :Artifacts, :PkgArtifacts)
                Base.depwarn("using Pkg instead of using LazyArtifacts is deprecated", :var"@artifact_str", force=true)
            end

Review comment (suggestion):
```suggestion
    return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))::String
```

Code after:

        # Move up a directory
        path = dirname(path)
    end

    # We never found anything, just return `nothing`
    return nothing
end

# We do this to avoid doing the `joinpath()` work if we don't have to, and also to
# avoid a trailing slash due to `joinpath()`'s habit of including one when the last
# argument is the empty string.
function jointail(dir, tail)
    if !isempty(tail)
        return joinpath(dir, tail)
    else
        return dir
    end
end

function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
    world = Base._require_world_age[]
    if world == typemax(UInt)
        world = Base.get_world_counter()
    end
    return Base.invoke_in_world(world, __artifact_str, __module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, Val(LazyArtifacts))::String
end

function __artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, ::Val{LazyArtifacts}) where LazyArtifacts
    pkg = Base.PkgId(__module__)
    if pkg.uuid !== nothing
        # Process overrides for this UUID, if we know what it is
        process_overrides(artifact_dict, pkg.uuid)
    end

    # If the artifact exists, we're in the happy path and we can immediately
    # return the path to the artifact:
    dirs = artifact_paths(hash; honor_overrides=true)
    for dir in dirs
        if isdir(dir)
            return jointail(dir, path_tail)
        end
    end

    # If not, try determining what went wrong:
    meta = artifact_meta(name, artifact_dict, artifacts_toml; platform)
    if meta !== nothing && get(meta, "lazy", false)
        if LazyArtifacts isa Module && isdefined(LazyArtifacts, :ensure_artifact_installed)
            if nameof(LazyArtifacts) in (:Pkg, :Artifacts, :PkgArtifacts)
                Base.depwarn("using Pkg instead of using LazyArtifacts is deprecated", :var"@artifact_str", force=true)
            end