Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
raphasampaio committed Dec 9, 2024
1 parent e4b9e2f commit 37dabaf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/deploy/psrmodels.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
function get_key(contents::Pair)
return contents.second
end

function get_key(contents::Dict)
return contents["Key"]
end

function generate_unique_key(; bucket::AbstractString, version::AbstractString, target::AbstractString, setup_zip::AbstractString, overwrite::Bool = false)
objects = S3.list_objects_v2(bucket, Dict("prefix" => target))
if haskey(objects, "Contents")
for contents in objects["Contents"]
key = contents["Key"]
key = get_key(contents)

if startswith(key, "$target/$version/")
if overwrite
Log.info("PSRMODELS: Overwriting the $setup_zip in the $bucket bucket")
Expand All @@ -22,7 +31,7 @@ function generate_unique_key(; bucket::AbstractString, version::AbstractString,
if haskey(objects, "Contents")
unique = true
for contents in objects["Contents"]
if key == contents["Key"]
if key == get_key(contents)
unique = false
break
end
Expand Down

0 comments on commit 37dabaf

Please sign in to comment.