Skip to content

Commit

Permalink
merge unneeded function
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Dec 1, 2019
1 parent 75f8b9c commit f54460f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dvc/remote/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,22 @@ def gdrive_upload_file(
item = self.drive.CreateFile(
{"title": args["title"], "parents": [{"id": args["parent_id"]}]}
)
self.upload_file(item, no_progress_bar, from_file, progress_name)
return item

def upload_file(self, item, no_progress_bar, from_file, progress_name):
with open(from_file, "rb") as fobj:
total = os.fstat(fobj.fileno()).st_size
total = os.path.getsize(from_file)
with Tqdm.wrapattr(
fobj,
"read",
desc=progress_name,
total=total,
disable=no_progress_bar,
) as opened_file:
) as wrapped:
# PyDrive doesn't like content property setting for empty files
# https://github.com/gsuitedevs/PyDrive/issues/121
if total:
item.content = opened_file
item.content = wrapped
item.Upload()
return item

@gdrive_retry
def gdrive_download_file(
Expand Down

0 comments on commit f54460f

Please sign in to comment.