Show More
@@ -94,15 +94,12 b' class nullvfs(lfsvfs):' | |||||
94 | pass |
|
94 | pass | |
95 |
|
95 | |||
96 |
|
96 | |||
97 |
class file |
|
97 | class lfsuploadfile(object): | |
98 | """a file-like object that supports __len__ and read. |
|
98 | """a file-like object that supports __len__ and read. | |
99 |
|
||||
100 | Useful to provide progress information for how many bytes are read. |
|
|||
101 | """ |
|
99 | """ | |
102 |
|
100 | |||
103 |
def __init__(self, fp |
|
101 | def __init__(self, fp): | |
104 | self._fp = fp |
|
102 | self._fp = fp | |
105 | self._callback = callback # func(readsize) |
|
|||
106 | fp.seek(0, os.SEEK_END) |
|
103 | fp.seek(0, os.SEEK_END) | |
107 | self._len = fp.tell() |
|
104 | self._len = fp.tell() | |
108 | fp.seek(0) |
|
105 | fp.seek(0) | |
@@ -114,10 +111,7 b' class filewithprogress(object):' | |||||
114 | if self._fp is None: |
|
111 | if self._fp is None: | |
115 | return b'' |
|
112 | return b'' | |
116 | data = self._fp.read(size) |
|
113 | data = self._fp.read(size) | |
117 | if data: |
|
114 | if not data: | |
118 | if self._callback: |
|
|||
119 | self._callback(len(data)) |
|
|||
120 | else: |
|
|||
121 | self._fp.close() |
|
115 | self._fp.close() | |
122 | self._fp = None |
|
116 | self._fp = None | |
123 | return data |
|
117 | return data | |
@@ -495,7 +489,7 b' class _gitlfsremote(object):' | |||||
495 | _(b'detected corrupt lfs object: %s') % oid, |
|
489 | _(b'detected corrupt lfs object: %s') % oid, | |
496 | hint=_(b'run hg verify'), |
|
490 | hint=_(b'run hg verify'), | |
497 | ) |
|
491 | ) | |
498 |
request.data = file |
|
492 | request.data = lfsuploadfile(localstore.open(oid)) | |
499 | request.get_method = lambda: r'PUT' |
|
493 | request.get_method = lambda: r'PUT' | |
500 | request.add_header('Content-Type', 'application/octet-stream') |
|
494 | request.add_header('Content-Type', 'application/octet-stream') | |
501 | request.add_header('Content-Length', len(request.data)) |
|
495 | request.add_header('Content-Length', len(request.data)) |
General Comments 0
You need to be logged in to leave comments.
Login now