Skip to content

Commit

Permalink
a bit more type stability
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Feb 4, 2022
1 parent 35c24e3 commit 3928a18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "AssetRegistry"
uuid = "bf4720bc-e11a-5d0c-854e-bdca1663c893"
license = "MIT"
version = "0.1.0"

[deps]
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Pidfile = "fa939f87-e72e-5be4-a000-7fc836dbe307"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
JSON = "0.21, 1.0"
Pidfile = "1.2.0"
6 changes: 3 additions & 3 deletions src/AssetRegistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ function register(path; registry_file = joinpath(homedir(), ".jlassetregistry.js
fkey = filekey(key)
io = open(registry_file, "r+") # open in read-and-write mode
# first get existing entries
prev_registry = filesize(io) > 0 ? JSON.parse(io) : Dict{String,Tuple{String,Int}}()
prev_registry = filesize(io) > 0 ? JSON.parse(io) : Dict{String,Vecto{Union{String,Int}}}()

if haskey(prev_registry, fkey)
prev_registry[fkey] = (target, prev_registry[fkey][2]+1) # increment ref count
prev_registry[fkey] = [target, prev_registry[fkey][2]+1] # increment ref count
else
prev_registry[fkey] = (target, 1) # init refcount to 1
prev_registry[fkey] = [target, 1] # init refcount to 1
end

# write the updated registry to file
Expand Down

0 comments on commit 3928a18

Please sign in to comment.