Skip to content

Commit 4821aa2

Browse files
committed
s3: catch specific exception when head_object()
1 parent da0d9e8 commit 4821aa2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dvc/remote/s3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import threading
77

8+
from botocore.exceptions import ClientError
89
from funcy import cached_property, wrap_prop
910

1011
from dvc.config import Config
@@ -212,8 +213,8 @@ def isfile(self, path_info):
212213
return False
213214

214215
try:
215-
self.get_head_object(self.s3, path_info.bucket, path_info.path)
216-
except DvcException:
216+
self.s3.head_object(Bucket=path_info.bucket, Key=path_info.path)
217+
except ClientError:
217218
return False
218219

219220
return True
@@ -224,7 +225,7 @@ def exists(self, path_info):
224225
225226
eg: if `data/file.txt` exists, check for `data` should return True
226227
"""
227-
return True if self.isfile(path_info) else self.isdir(path_info)
228+
return self.isfile(path_info) or self.isdir(path_info)
228229

229230
def makedirs(self, path_info):
230231
# We need to support creating empty directories, which means

0 commit comments

Comments
 (0)