Skip to content

Commit

Permalink
s3: catch specific exception when head_object()
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Dec 1, 2019
1 parent da0d9e8 commit 4821aa2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dvc/remote/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import threading

from botocore.exceptions import ClientError
from funcy import cached_property, wrap_prop

from dvc.config import Config
Expand Down Expand Up @@ -212,8 +213,8 @@ def isfile(self, path_info):
return False

try:
self.get_head_object(self.s3, path_info.bucket, path_info.path)
except DvcException:
self.s3.head_object(Bucket=path_info.bucket, Key=path_info.path)
except ClientError:
return False

return True
Expand All @@ -224,7 +225,7 @@ def exists(self, path_info):
eg: if `data/file.txt` exists, check for `data` should return True
"""
return True if self.isfile(path_info) else self.isdir(path_info)
return self.isfile(path_info) or self.isdir(path_info)

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

0 comments on commit 4821aa2

Please sign in to comment.