##// END OF EJS Templates
streamclone: ensure the server sends the right amount of data...
Valentin Gatien-Baron -
r48592:48f07adb stable
parent child Browse files
Show More
@@ -583,7 +583,7 b' def _emit2(repo, entries, totalfilesize)'
583 583 # copy is delayed until we are in the try
584 584 entries = [_filterfull(e, copy, vfsmap) for e in entries]
585 585 yield None # this release the lock on the repository
586 seen = 0
586 totalbytecount = 0
587 587
588 588 for src, name, ftype, data in entries:
589 589 vfs = vfsmap[src]
@@ -595,6 +595,7 b' def _emit2(repo, entries, totalfilesize)'
595 595 elif ftype == _filefull:
596 596 fp = open(data, b'rb')
597 597 size = util.fstat(fp).st_size
598 bytecount = 0
598 599 try:
599 600 yield util.uvarintencode(size)
600 601 yield name
@@ -603,9 +604,20 b' def _emit2(repo, entries, totalfilesize)'
603 604 else:
604 605 chunks = util.filechunkiter(fp, limit=size)
605 606 for chunk in chunks:
606 seen += len(chunk)
607 progress.update(seen)
607 bytecount += len(chunk)
608 totalbytecount += len(chunk)
609 progress.update(totalbytecount)
608 610 yield chunk
611 if bytecount != size:
612 # Would most likely be caused by a race due to `hg strip` or
613 # a revlog split
614 raise error.Abort(
615 _(
616 b'clone could only read %d bytes from %s, but '
617 b'expected %d bytes'
618 )
619 % (bytecount, name, size)
620 )
609 621 finally:
610 622 fp.close()
611 623
General Comments 0
You need to be logged in to leave comments. Login now