gdrive: don't use hacks for empty files (#4588)

This bug is fixed in PyDrive2 1.6.2.
This commit is contained in:
Ruslan Kuprieiev
2020-09-21 20:23:19 +03:00
committed by GitHub
parent 15488ebefd
commit 0b9cd4c93c
2 changed files with 3 additions and 15 deletions
+2 -14
View File
@@ -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
+1 -1
View File
@@ -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"]