onedrive-d-old icon indicating copy to clipboard operation
onedrive-d-old copied to clipboard

Future branch: JSONDecodeError while downloading file (last block?)

Open msunela opened this issue 9 years ago • 6 comments

Using the future branch, the sync dies after awhile with following exception:

[2015-02-28 13:42:36,611] DEBUG: worker0: download block 6291456 - 6399352 (total: 6399353 B)
Exception in thread worker0:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/dist-packages/onedrive_d-1.0.0dev-py3.4.egg/onedrive_d/od_worker_thread.py", line 456, in run
    self.download_file(task)
  File "/usr/local/lib/python3.4/dist-packages/onedrive_d-1.0.0dev-py3.4.egg/onedrive_d/od_worker_thread.py", line 398, in download_file
    if not self.api.get_by_blocks(task['remote_id'], task['local_path'], entry['size'], self.config.params['BITS_BLOCK_SIZE']):
  File "/usr/local/lib/python3.4/dist-packages/onedrive_d-1.0.0dev-py3.4.egg/onedrive_d/od_onedrive_api.py", line 572, in get_by_blocks
    ret = r.json()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 741, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 488, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

msunela avatar Feb 28 '15 12:02 msunela

All the worker threads die one by one with the same exception, for example: [2015-02-28 14:00:42,658] DEBUG: worker2: download block 6291456 - 6452910 (total: 6452911 B)

msunela avatar Feb 28 '15 12:02 msunela

We need to figure out what stuff JSONDecoder is complaining about.

Could you open your copy of onedrive_d/od_onedrive_api.py, find line 553 which starts the function def get_by_blocks, and below it find line 572

ret = r.json()

Add lines above that one

print(r.status_code)
print(r.text)

with same indentation, and run the program (if you installed it on your system, you may need to uninstall it, and run onedrive-d in the way "Run without installation" section says) and see what is printed out?

From the exception, we know the server, when encountering some error, is not returning JSON text as it is supposed to. But I can't reproduce the problem with my own OneDrive data. If you can help with debugging I really appreciate it.

xybu avatar Feb 28 '15 13:02 xybu

Okay, here's the result: [2015-02-28 18:21:22,586] DEBUG: worker0: download block 6291456 - 6399352 (total: 6399353 B) 416

Exception in thread worker0: Traceback (most recent call last): [...]

msunela avatar Feb 28 '15 16:02 msunela

According to OneDrive docs (http://onedrive.github.io/items/upload_large_files.htm) it is:

Notes: * The nextExpectedRanges property won't always list all of the missing ranges. * On successful fragment writes, it will return the next range to start from (eg. "523-"). * On failures when the client sent a fragment the server had already received, the server will respond with HTTP 416 Requested Range Not Satisfiable. You can request upload status to get a more detailed list of missing ranges.

msunela avatar Feb 28 '15 16:02 msunela

The scenario is file downloading, not file uploading. Something else happened. (e.g., file size changed while requesting? idk.) I have some revisions on both uploading and downloading that have not been pushed. They should be more adaptive. But there is some server side assertion exception that still fails #126 and I am waiting for tech support.

xybu avatar Mar 03 '15 03:03 xybu

@msunela You shared a very very very interesting link. Never realized this set of API. Looked promising. I opened an issue #128 just in case I forget.

xybu avatar Mar 03 '15 03:03 xybu