From 4821aa2efa8536b860bde9f26d181b59edf363c7 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Sun, 1 Dec 2019 14:47:56 +0545 Subject: [PATCH] s3: catch specific exception when head_object() --- dvc/remote/s3.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dvc/remote/s3.py b/dvc/remote/s3.py index 2f006135c..66e53cebe 100644 --- a/dvc/remote/s3.py +++ b/dvc/remote/s3.py @@ -5,6 +5,7 @@ import logging import os import threading +from botocore.exceptions import ClientError from funcy import cached_property, wrap_prop from dvc.config import Config @@ -212,8 +213,8 @@ class RemoteS3(RemoteBASE): 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 @@ -224,7 +225,7 @@ class RemoteS3(RemoteBASE): 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