From ee69ac835d9453fb804e71ed9011552a2461c1cb Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Fri, 29 Nov 2019 07:22:15 +0545 Subject: [PATCH] gs: make it work with empty dir --- dvc/remote/gs.py | 8 ++++++++ tests/func/test_remote_dir.py | 1 + 2 files changed, 9 insertions(+) diff --git a/dvc/remote/gs.py b/dvc/remote/gs.py index 6fdd1d4b1..bfbd51010 100644 --- a/dvc/remote/gs.py +++ b/dvc/remote/gs.py @@ -148,8 +148,16 @@ class RemoteGS(RemoteBASE): def walk_files(self, path_info): for fname in self._list_paths(path_info.bucket, path_info.path): + # skip nested empty directories + if fname.endswith("/"): + continue yield path_info.replace(fname) + def makedirs(self, path_info): + self.gs.bucket(path_info.bucket).blob( + (path_info / "").path + ).upload_from_string("") + def isdir(self, path_info): dir_path = path_info / "" return bool( diff --git a/tests/func/test_remote_dir.py b/tests/func/test_remote_dir.py index 81fa7b362..b78f80041 100644 --- a/tests/func/test_remote_dir.py +++ b/tests/func/test_remote_dir.py @@ -83,6 +83,7 @@ def remote_gs(): put_object("data/subdir/1", "1") put_object("data/subdir/2", "2") put_object("data/subdir/3", "3") + put_object("data/subdir/4/", "") yield remote