From 7bd29bf69ad4873d88731bc26eef205dea9d219f Mon Sep 17 00:00:00 2001 From: Ismael Date: Fri, 23 Aug 2024 16:57:58 -0400 Subject: [PATCH] Use head_object to check for object existence --- CHANGELOG.rst | 5 +++++ VERSION | 2 +- guillotina_s3storage/storage.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 192c239..c220f21 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +5.1.2 +------------------- + +- Use head_object to check for object existence + 5.1.1 (unreleased) ------------------- diff --git a/VERSION b/VERSION index ac14c3d..61fcc87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.1.1 +5.1.2 diff --git a/guillotina_s3storage/storage.py b/guillotina_s3storage/storage.py index c0b549d..94e3146 100644 --- a/guillotina_s3storage/storage.py +++ b/guillotina_s3storage/storage.py @@ -262,7 +262,7 @@ async def exists(self): util = get_utility(IS3BlobStore) try: async with util.s3_client() as client: - return await client.get_object(Bucket=bucket, Key=uri) is not None + return await client.head_object(Bucket=bucket, Key=uri) is not None except botocore.exceptions.ClientError as ex: if ex.response["Error"]["Code"] == "NoSuchKey": return False