Fix downloading zero-byte files (#301)

This commit is contained in:
Mohamed Akram 2020-10-15 18:36:36 +04:00 committed by GitHub
parent 0efc4f4f5d
commit 09652b0d27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,12 @@
"""Drive service.""" """Drive service."""
from datetime import datetime, timedelta from datetime import datetime, timedelta
import json import json
import io
import mimetypes import mimetypes
import os import os
import time import time
from re import search from re import search
from requests import Response
from six import PY2 from six import PY2
@ -260,6 +262,11 @@ class DriveNode(object):
def open(self, **kwargs): def open(self, **kwargs):
"""Gets the node file.""" """Gets the node file."""
# iCloud returns 400 Bad Request for 0-byte files
if self.data["size"] == 0:
response = Response()
response.raw = io.BytesIO()
return response
return self.connection.get_file(self.data["docwsid"], **kwargs) return self.connection.get_file(self.data["docwsid"], **kwargs)
def upload(self, file_object, **kwargs): def upload(self, file_object, **kwargs):