Skip to content

Commit

Permalink
AE-2274: Refactor existence checking to be passed as an option enclos…
Browse files Browse the repository at this point in the history
…ed in a map
  • Loading branch information
solita-juhohaa committed Oct 16, 2024
1 parent 33961b1 commit 94de70a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

(defn get-object-head
([aws-s3-client key]
(get-object-head aws-s3-client key false))
([{:keys [client bucket]} key checking-for-existence?]
(get-object-head aws-s3-client key {:checking-for-existence? false}))
([{:keys [client bucket]} key options]
(aws.utils/invoke client
:HeadObject
{:Bucket bucket
:Key key}
checking-for-existence?)))
options)))

(defn delete-object [{:keys [client bucket]} key]
(aws.utils/invoke client
Expand Down
4 changes: 2 additions & 2 deletions etp-core/etp-backend/src/main/clj/solita/common/aws/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

(defn invoke
([client op request]
(invoke client op request false))
([client op request checking-for-existence?]
(invoke client op request {:checking-for-existence? false}))
([client op request {:keys [checking-for-existence?]}]
(let [result (aws/invoke client {:op op
:request request})]
(if (contains? result :cognitect.anomalies/category)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

(defn file-exists? [aws-s3-client key]
(try
(s3/get-object-head aws-s3-client key true)
(s3/get-object-head aws-s3-client key {:checking-for-existence? true})
true
(catch ExceptionInfo e
(let [{:keys [type]} (ex-data e)]
Expand Down

0 comments on commit 94de70a

Please sign in to comment.