Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG4da09b46451e: lfs: add some bytestring wrappers in blobstore.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
import re | import re | ||||
import socket | import socket | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial import ( | from mercurial import ( | ||||
error, | error, | ||||
pathutil, | pathutil, | ||||
pycompat, | |||||
url as urlmod, | url as urlmod, | ||||
util, | util, | ||||
vfs as vfsmod, | vfs as vfsmod, | ||||
worker, | worker, | ||||
) | ) | ||||
from ..largefiles import lfutil | from ..largefiles import lfutil | ||||
obj: dict, an object description returned by batch API | obj: dict, an object description returned by batch API | ||||
action: string, one of ['upload', 'download'] | action: string, one of ['upload', 'download'] | ||||
localstore: blobstore.local | localstore: blobstore.local | ||||
See https://github.com/git-lfs/git-lfs/blob/master/docs/api/\ | See https://github.com/git-lfs/git-lfs/blob/master/docs/api/\ | ||||
basic-transfers.md | basic-transfers.md | ||||
""" | """ | ||||
oid = str(obj['oid']) | oid = pycompat.bytestr(obj['oid']) | ||||
href = str(obj['actions'][action].get('href')) | href = pycompat.bytestr(obj['actions'][action].get('href')) | ||||
headers = obj['actions'][action].get('header', {}).items() | headers = obj['actions'][action].get('header', {}).items() | ||||
request = util.urlreq.request(href) | request = util.urlreq.request(href) | ||||
if action == 'upload': | if action == 'upload': | ||||
# If uploading blobs, read data from local blobstore. | # If uploading blobs, read data from local blobstore. | ||||
with localstore.open(oid) as fp: | with localstore.open(oid) as fp: | ||||
_verifyfile(oid, fp) | _verifyfile(oid, fp) | ||||
request.data = filewithprogress(localstore.open(oid), None) | request.data = filewithprogress(localstore.open(oid), None) |