only check resume file if set
This commit is contained in:
parent
9e40462d78
commit
69b6e08731
1 changed files with 10 additions and 9 deletions
|
@ -1078,7 +1078,7 @@ class API(ox.API):
|
||||||
def upload_chunks(self, url, filename, data=None):
|
def upload_chunks(self, url, filename, data=None):
|
||||||
form = ox.MultiPartForm()
|
form = ox.MultiPartForm()
|
||||||
resume = None
|
resume = None
|
||||||
if os.path.exists(self._resume_file):
|
if self._resume_file and os.path.exists(self._resume_file):
|
||||||
with open(self._resume_file) as f:
|
with open(self._resume_file) as f:
|
||||||
try:
|
try:
|
||||||
resume = json.load(f)
|
resume = json.load(f)
|
||||||
|
@ -1165,15 +1165,16 @@ class API(ox.API):
|
||||||
print('server offset out of sync, continue from', data['offset'])
|
print('server offset out of sync, continue from', data['offset'])
|
||||||
done = data['offset']
|
done = data['offset']
|
||||||
f.seek(done)
|
f.seek(done)
|
||||||
with open(self._resume_file, 'w') as r:
|
if self._resume_file:
|
||||||
json.dump({
|
with open(self._resume_file, 'w') as r:
|
||||||
'uploadUrl': uploadUrl,
|
json.dump({
|
||||||
'chunkUploadUrl': url,
|
'uploadUrl': uploadUrl,
|
||||||
'url': result_url,
|
'chunkUploadUrl': url,
|
||||||
'offset': done
|
'url': result_url,
|
||||||
}, r, indent=2)
|
'offset': done
|
||||||
|
}, r, indent=2)
|
||||||
chunk = f.read(CHUNK_SIZE)
|
chunk = f.read(CHUNK_SIZE)
|
||||||
if os.path.exists(self._resume_file):
|
if self._resume_file and os.path.exists(self._resume_file):
|
||||||
os.unlink(self._resume_file)
|
os.unlink(self._resume_file)
|
||||||
resume = None
|
resume = None
|
||||||
if result_url:
|
if result_url:
|
||||||
|
|
Loading…
Reference in a new issue