From 94de70a0cbbe5e41416962268d69eb5e1d840326 Mon Sep 17 00:00:00 2001 From: Juho Haapakoski Date: Wed, 16 Oct 2024 17:53:51 +0300 Subject: [PATCH] AE-2274: Refactor existence checking to be passed as an option enclosed in a map --- etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj | 6 +++--- .../etp-backend/src/main/clj/solita/common/aws/utils.clj | 4 ++-- .../etp-backend/src/main/clj/solita/etp/service/file.clj | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj b/etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj index 4aaa82fb2..0f553f4eb 100644 --- a/etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj +++ b/etp-core/etp-backend/src/main/clj/solita/common/aws/s3.clj @@ -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 diff --git a/etp-core/etp-backend/src/main/clj/solita/common/aws/utils.clj b/etp-core/etp-backend/src/main/clj/solita/common/aws/utils.clj index f90d66524..8fc650260 100644 --- a/etp-core/etp-backend/src/main/clj/solita/common/aws/utils.clj +++ b/etp-core/etp-backend/src/main/clj/solita/common/aws/utils.clj @@ -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) diff --git a/etp-core/etp-backend/src/main/clj/solita/etp/service/file.clj b/etp-core/etp-backend/src/main/clj/solita/etp/service/file.clj index 5abbf16e0..99c15ebca 100644 --- a/etp-core/etp-backend/src/main/clj/solita/etp/service/file.clj +++ b/etp-core/etp-backend/src/main/clj/solita/etp/service/file.clj @@ -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)]