166 # If the server advertised a length longer than what we actually |
166 # If the server advertised a length longer than what we actually |
167 # received, then we should expect that the server crashed while |
167 # received, then we should expect that the server crashed while |
168 # producing the response (but the server has no way of telling us |
168 # producing the response (but the server has no way of telling us |
169 # that), and we really don't need to try to write the response to |
169 # that), and we really don't need to try to write the response to |
170 # the localstore, because it's not going to match the expected. |
170 # the localstore, because it's not going to match the expected. |
|
171 # The server also uses this method to store data uploaded by the |
|
172 # client, so if this happens on the server side, it's possible |
|
173 # that the client crashed or an antivirus interfered with the |
|
174 # upload. |
171 if content_length is not None and int(content_length) != size: |
175 if content_length is not None and int(content_length) != size: |
172 msg = ( |
176 msg = ( |
173 b"Response length (%d) does not match Content-Length " |
177 b"Response length (%d) does not match Content-Length " |
174 b"header (%d): likely server-side crash" |
178 b"header (%d) for %s" |
175 ) |
179 ) |
176 raise LfsRemoteError(_(msg) % (size, int(content_length))) |
180 raise LfsRemoteError(_(msg) % (size, int(content_length), oid)) |
177 |
181 |
178 realoid = hex(sha256.digest()) |
182 realoid = hex(sha256.digest()) |
179 if realoid != oid: |
183 if realoid != oid: |
180 raise LfsCorruptionError( |
184 raise LfsCorruptionError( |
181 _(b'corrupt remote lfs object: %s') % oid |
185 _(b'corrupt remote lfs object: %s') % oid |