##// END OF EJS Templates
lfs: fix the stall and corruption issue when concurrently uploading blobs...
Matt Harbison -
r44746:43eea17a default
parent child Browse files
Show More
@@ -21,6 +21,7 b' from mercurial.pycompat import getattr'
21 21 from mercurial import (
22 22 encoding,
23 23 error,
24 httpconnection as httpconnectionmod,
24 25 node,
25 26 pathutil,
26 27 pycompat,
@@ -94,28 +95,16 b' class nullvfs(lfsvfs):'
94 95 pass
95 96
96 97
97 class lfsuploadfile(object):
98 """a file-like object that supports __len__ and read.
98 class lfsuploadfile(httpconnectionmod.httpsendfile):
99 """a file-like object that supports keepalive.
99 100 """
100 101
101 def __init__(self, fp):
102 self._fp = fp
103 fp.seek(0, os.SEEK_END)
104 self._len = fp.tell()
105 fp.seek(0)
106
107 def __len__(self):
108 return self._len
102 def __init__(self, ui, filename):
103 super(lfsuploadfile, self).__init__(ui, filename, b'rb')
104 self.read = self._data.read
109 105
110 def read(self, size):
111 if self._fp is None:
112 return b''
113 return self._fp.read(size)
114
115 def close(self):
116 if self._fp is not None:
117 self._fp.close()
118 self._fp = None
106 def _makeprogress(self):
107 return None # progress is handled by the worker client
119 108
120 109
121 110 class local(object):
@@ -507,10 +496,10 b' class _gitlfsremote(object):'
507 496
508 497 try:
509 498 if action == b'upload':
510 request.data = lfsuploadfile(localstore.open(oid))
499 request.data = lfsuploadfile(self.ui, localstore.path(oid))
511 500 request.get_method = lambda: 'PUT'
512 501 request.add_header('Content-Type', 'application/octet-stream')
513 request.add_header('Content-Length', len(request.data))
502 request.add_header('Content-Length', request.data.length)
514 503
515 504 with contextlib.closing(self.urlopener.open(request)) as res:
516 505 contentlength = res.info().get(b"content-length")
General Comments 0
You need to be logged in to leave comments. Login now