##// END OF EJS Templates
lfs: only hardlink between the usercache and local store if the blob verifies...
Matt Harbison -
r35493:bb6a80fc @10 default
parent child Browse files
Show More
@@ -111,15 +111,23 b' class local(object):'
111 # XXX: should we verify the content of the cache, and hardlink back to
111 # XXX: should we verify the content of the cache, and hardlink back to
112 # the local store on success, but truncate, write and link on failure?
112 # the local store on success, but truncate, write and link on failure?
113 if not self.cachevfs.exists(oid):
113 if not self.cachevfs.exists(oid):
114 self.ui.note(_('lfs: adding %s to the usercache\n') % oid)
114 if verify or hashlib.sha256(data).hexdigest() == oid:
115 lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid))
115 self.ui.note(_('lfs: adding %s to the usercache\n') % oid)
116 lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid))
116
117
117 def read(self, oid, verify=True):
118 def read(self, oid, verify=True):
118 """Read blob from local blobstore."""
119 """Read blob from local blobstore."""
119 if not self.vfs.exists(oid):
120 if not self.vfs.exists(oid):
120 blob = self._read(self.cachevfs, oid, verify)
121 blob = self._read(self.cachevfs, oid, verify)
121 self.ui.note(_('lfs: found %s in the usercache\n') % oid)
122
122 lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid))
123 # Even if revlog will verify the content, it needs to be verified
124 # now before making the hardlink to avoid propagating corrupt blobs.
125 # Don't abort if corruption is detected, because `hg verify` will
126 # give more useful info about the corruption- simply don't add the
127 # hardlink.
128 if verify or hashlib.sha256(blob).hexdigest() == oid:
129 self.ui.note(_('lfs: found %s in the usercache\n') % oid)
130 lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid))
123 else:
131 else:
124 self.ui.note(_('lfs: found %s in the local lfs store\n') % oid)
132 self.ui.note(_('lfs: found %s in the local lfs store\n') % oid)
125 blob = self._read(self.vfs, oid, verify)
133 blob = self._read(self.vfs, oid, verify)
@@ -658,8 +658,8 b' the (uncorrupted) remote store.'
658 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
658 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
659 4 files, 5 changesets, 10 total revisions
659 4 files, 5 changesets, 10 total revisions
660
660
661 BUG: Verify will copy/link a corrupted file from the usercache into the local
661 Verify will not copy/link a corrupted file from the usercache into the local
662 store, and poison it. (The verify with a good remote now fails.)
662 store, and poison it. (The verify with a good remote now works.)
663
663
664 $ rm -r fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
664 $ rm -r fromcorrupt/.hg/store/lfs/objects/66/100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
665 $ hg -R fromcorrupt verify -v
665 $ hg -R fromcorrupt verify -v
@@ -668,10 +668,8 b' store, and poison it. (The verify with '
668 checking manifests
668 checking manifests
669 crosschecking files in changesets and manifests
669 crosschecking files in changesets and manifests
670 checking files
670 checking files
671 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the usercache
672 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
671 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
673 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
672 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
674 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
675 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
673 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
676 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
674 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
677 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
675 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
@@ -685,17 +683,12 b' store, and poison it. (The verify with '
685 checking manifests
683 checking manifests
686 crosschecking files in changesets and manifests
684 crosschecking files in changesets and manifests
687 checking files
685 checking files
688 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
686 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the usercache
689 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
690 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
687 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
691 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
688 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
692 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
693 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
689 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
694 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
690 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
695 4 files, 5 changesets, 10 total revisions
691 4 files, 5 changesets, 10 total revisions
696 2 integrity errors encountered!
697 (first damaged changeset appears to be 0)
698 [1]
699
692
700 Damaging a file required by the update destination fails the update.
693 Damaging a file required by the update destination fails the update.
701
694
@@ -739,7 +732,6 b' avoids the corrupt lfs object in the ori'
739 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
732 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
740 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
733 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
741 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
734 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
742 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
743 abort: detected corrupt lfs object: 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
735 abort: detected corrupt lfs object: 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e
744 (run hg verify)
736 (run hg verify)
745 [255]
737 [255]
@@ -750,10 +742,8 b' avoids the corrupt lfs object in the ori'
750 checking manifests
742 checking manifests
751 crosschecking files in changesets and manifests
743 crosschecking files in changesets and manifests
752 checking files
744 checking files
753 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
754 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
745 l@1: unpacking 46a2f24864bc: integrity check failed on data/l.i:0
755 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
746 lfs: found 22f66a3fc0b9bf3f012c814303995ec07099b3a9ce02a7af84b5970811074a3b in the local lfs store
756 lfs: found 66100b384bf761271b407d79fc30cdd0554f3b2c5d944836e936d584b88ce88e in the local lfs store
757 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
747 large@0: unpacking 2c531e0992ff: integrity check failed on data/large.i:0
758 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
748 lfs: found 89b6070915a3d573ff3599d1cda305bc5e38549b15c4847ab034169da66e1ca8 in the local lfs store
759 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
749 lfs: found b1a6ea88da0017a0e77db139a54618986e9a2489bee24af9fe596de9daac498c in the local lfs store
General Comments 0
You need to be logged in to leave comments. Login now