From 8a62e2f92bbc4a0ea54dc7607ae3c0241c5fab58 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Sat, 30 Nov 2019 18:03:41 +0545 Subject: [PATCH] gs: check if the path is directory when checking for exists --- dvc/remote/gs.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index 584977636..35477e1fd 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -148,7 +148,7 @@ class RemoteGS(RemoteBASE): return self._list_paths(self.path_info) def walk_files(self, path_info): - for fname in self._list_paths(path_info): + for fname in self._list_paths(path_info / ""): # skip nested empty directories if fname.endswith("/"): continue @@ -165,8 +165,13 @@ class RemoteGS(RemoteBASE): def exists(self, path_info): dir_path = path_info / "" - fname = next(self._list_paths(path_info, max_items=1), "") - return path_info.path == fname or fname.startswith(dir_path.path) + + if self.isdir(dir_path): + return True + + for fname in self._list_paths(path_info): + if path_info.path == fname: + return True def _upload(self, from_file, to_info, name=None, no_progress_bar=True): bucket = self.gs.bucket(to_info.bucket)