From 7521e91d0586d6737ae4b3dd9951b42930c4af57 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Wed, 15 Sep 2021 16:12:46 +0545 Subject: [PATCH] Strip bucket on GdriveFileSystem (#6618) --- dvc/fs/gdrive.py | 9 +++++++++ tests/func/test_fs.py | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dvc/fs/gdrive.py b/dvc/fs/gdrive.py index d49ad6bad..a3d7f1201 100644 --- a/dvc/fs/gdrive.py +++ b/dvc/fs/gdrive.py @@ -296,6 +296,15 @@ class GDriveFileSystem(FSSpecWrapper): # pylint:disable=abstract-method return super()._with_bucket(path) + def _strip_bucket(self, entry): + try: + bucket, path = entry.split("/", 1) + except ValueError: + # If there is no path attached, only returns + # the bucket (top-level). + bucket, path = entry, None + return path or bucket + def upload_fobj(self, fobj, to_info, **kwargs): rpath = self._with_bucket(to_info) self.makedirs(os.path.dirname(rpath)) diff --git a/tests/func/test_fs.py b/tests/func/test_fs.py index 020f598f6..eadd8ae8c 100644 --- a/tests/func/test_fs.py +++ b/tests/func/test_fs.py @@ -493,9 +493,7 @@ def test_download_callback(tmp_dir, dvc, cloud): os.name == "nt", reason="unsupported on Windows." ), ), - pytest.param( - pytest.lazy_fixture("gdrive"), marks=pytest.mark.xfail(strict=True) - ), + pytest.lazy_fixture("gdrive"), ], ) def test_download_dir_callback(tmp_dir, dvc, cloud):