mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
lfs: handle batch API's HTTP and JSON error
Summary: There are `1+n` HTTP requests. `n` of them is handled. But the first one about JSON metadata is not. Let's handle it. Test Plan: arc unit Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5057053 Signature: t1:5057053:1494634184:fa0e562dc7879379106bf37915a2e5ea3cc01a4d
This commit is contained in:
parent
d5e501b573
commit
853b228a8a
@ -75,9 +75,16 @@ class _gitlfsremote(object):
|
||||
data=requestdata)
|
||||
batchreq.add_header('Accept', 'application/vnd.git-lfs+json')
|
||||
batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json')
|
||||
raw_response = self.urlopener.open(batchreq)
|
||||
response = json.loads(raw_response.read())
|
||||
|
||||
try:
|
||||
rawjson = self.urlopener.open(batchreq).read()
|
||||
except util.urlerr.httperror as ex:
|
||||
raise LfsRemoteError(_('LFS HTTP error: %s (action=%s)')
|
||||
% (ex, action))
|
||||
try:
|
||||
response = json.loads(rawjson)
|
||||
except ValueError:
|
||||
raise LfsRemoteError(_('LFS server returns invalid JSON: %s')
|
||||
% rawjson)
|
||||
topic = {'upload': _('lfs uploading'),
|
||||
'download': _('lfs downloading')}[action]
|
||||
runningsize = 0
|
||||
|
Loading…
Reference in New Issue
Block a user