From 0b9cd4c93c5d9074edd0910d64b92c5dcc8ddfae Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Mon, 21 Sep 2020 20:23:19 +0300 Subject: [PATCH] gdrive: don't use hacks for empty files (#4588) This bug is fixed in PyDrive2 1.6.2. --- dvc/tree/gdrive.py | 16 ++-------------- setup.py | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/dvc/tree/gdrive.py b/dvc/tree/gdrive.py index 12779a5c3..302a5ccda 100644 --- a/dvc/tree/gdrive.py +++ b/dvc/tree/gdrive.py @@ -366,10 +366,7 @@ class GDriveTree(BaseTree): total=total, disable=no_progress_bar, ) as wrapped: - # PyDrive doesn't like content property setting for empty files - # https://github.com/gsuitedevs/PyDrive/issues/121 - if total: - item.content = wrapped + item.content = wrapped item.Upload() return item @@ -381,9 +378,6 @@ class GDriveTree(BaseTree): # it does not create a file on the remote gdrive_file = self._drive.CreateFile(param) - gdrive_file.FetchMetadata(fields="fileSize") - size = int(gdrive_file["fileSize"]) - with Tqdm( desc=progress_desc, disable=no_progress_bar, @@ -391,13 +385,7 @@ class GDriveTree(BaseTree): # explicit `bar_format` as `total` will be set by `update_to` bar_format=Tqdm.BAR_FMT_DEFAULT, ) as pbar: - if size: - gdrive_file.GetContentFile(to_file, callback=pbar.update_to) - else: - # PyDrive doesn't like downloading empty files - # https://github.com/iterative/dvc/issues/4286 - with open(to_file, "w"): - pass + gdrive_file.GetContentFile(to_file, callback=pbar.update_to) @contextmanager @_gdrive_retry diff --git a/setup.py b/setup.py index ae7200af3..9579d1915 100644 --- a/setup.py +++ b/setup.py @@ -88,7 +88,7 @@ install_requires = [ # Extra dependencies for remote integrations gs = ["google-cloud-storage==1.19.0"] -gdrive = ["pydrive2>=1.6.1", "six >= 1.13.0"] +gdrive = ["pydrive2>=1.6.2", "six >= 1.13.0"] s3 = ["boto3>=1.9.201"] azure = ["azure-storage-blob>=12.0", "knack"] oss = ["oss2==2.6.1"]