Skip to content

Commit f36a492

Browse files
committed
fixup! Make mirror_file fail if file object already exists (#7134)
1 parent e517580 commit f36a492

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/azul/indexer/mirror_controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def mirror_file(self,
154154
and catalog not in config.integration_test_catalogs)
155155
if self.service.info_exists(catalog, file):
156156
log.info('File is already mirrored, skipping upload: %r', file)
157+
elif self.service.file_exists(catalog, file):
158+
assert False, R('File object is already present', file)
157159
elif file_is_large and not deployment_is_stable:
158160
log.info('Not mirroring file to save cost: %r', file)
159161
else:

src/azul/indexer/mirror_service.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ def info_object_key(self, file: File) -> str:
194194
def info_exists(self, catalog: CatalogName, file: File) -> bool:
195195
return self._get_info(catalog, file) is not None
196196

197+
def file_exists(self, catalog: CatalogName, file: File) -> bool:
198+
try:
199+
self._storage(catalog).head(self.mirror_object_key(file))
200+
except StorageObjectNotFound:
201+
return False
202+
else:
203+
return True
204+
197205
def _file_key(self, prefix: str, file: File, *, extension: str = '') -> str:
198206
digest = file.digest
199207
assert all(c in string.hexdigits for c in digest.value), R(

0 commit comments

Comments
 (0)