diff --git a/.gitignore b/.gitignore index 8c960ec..3f02ca7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.jl.cov *.jl.*.cov *.jl.mem +Manifest.toml diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..84bacb6 --- /dev/null +++ b/Project.toml @@ -0,0 +1,15 @@ +name = "AssetRegistry" +uuid = "bf4720bc-e11a-5d0c-854e-bdca1663c893" +version = "0.1.0" + +[deps] +JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +Pidfile = "fa939f87-e72e-5be4-a000-7fc836dbe307" +SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[extras] +Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test", "Distributed"] diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index 2265bed..0000000 --- a/REQUIRE +++ /dev/null @@ -1,3 +0,0 @@ -julia 0.7 -Pidfile -JSON diff --git a/src/AssetRegistry.jl b/src/AssetRegistry.jl index 9f392f1..028b46f 100644 --- a/src/AssetRegistry.jl +++ b/src/AssetRegistry.jl @@ -113,9 +113,15 @@ function deregister(path; registry_file = joinpath(homedir(), ".jlassetregistry. key end -getkey(path) = baseurl[] * "/assetserver/" * bytes2hex(sha1(abspath(path))) * "-" * basename(path) +generatekey(path) = baseurl[] * "/assetserver/" * bytes2hex(sha1(path)) * "-" * basename(path) -isregistered(path) = haskey(registry, getkey(path)) +isregistered(path) = normpath(abspath(expanduser(path))) in values(registry) + +function getkey(path) + target = normpath(abspath(expanduser(path))) + key = findfirst(x -> x == target, registry) + key === nothing ? generatekey(path) : key +end function __init__() baseurl[] = get(ENV, "JULIA_ASSETREGISTRY_BASEURL", get(ENV, "JUPYTERHUB_SERVICE_PREFIX", ""))