mirror of
https://github.com/facebook/sapling.git
synced 2024-12-28 07:33:10 +03:00
verify that received files have the correct size
Summary: Streaming clone implementation did not check that received files have the corrects. This change addresses it. Before this change if connection was interrupted for whatever reason client would treat fetch of changeset as successful and proceed with cloning operations, but later checks would report corruption of internal state of hg data. This is based on user [report](https://fb.workplace.com/groups/scm/permalink/3177150312334567/) Reviewed By: quark-zju, krallin Differential Revision: D23572058 fbshipit-source-id: d740b45ca217cd6db0a65e01aabc2ba9a4835221
This commit is contained in:
parent
384c4f61fa
commit
897ec3d6d8
@ -374,9 +374,17 @@ def consumev1(repo, fp, filecount, bytecount):
|
||||
# for backwards compat, name was partially encoded
|
||||
path = store.decodedir(decodeutf8(name))
|
||||
with repo.svfs(path, "w", backgroundclose=True) as ofp:
|
||||
fetchedsize = 0
|
||||
for chunk in util.filechunkiter(fp, limit=size):
|
||||
prog.value += len(chunk)
|
||||
ofp.write(chunk)
|
||||
chunksize = len(chunk)
|
||||
prog.value += chunksize
|
||||
fetchedsize += chunksize
|
||||
if fetchedsize != size:
|
||||
msg = _(
|
||||
"failed to fully fetch %s: fetched:%s expected:%s"
|
||||
) % (name, fetchedsize, size)
|
||||
raise error.Abort(msg)
|
||||
|
||||
# force @filecache properties to be reloaded from
|
||||
# streamclone-ed file at next access
|
||||
|
Loading…
Reference in New Issue
Block a user