comparison hgext/largefiles/localstore.py @ 29067:207c0db08953

largefiles: change basestore._verifyfile to take list of files to check Makes it easier to use batch stat calls in remotestore to decrease number of round trips.
author liscju <piotr.listkiewicz@gmail.com>
date Tue, 03 May 2016 23:31:32 +0200
parents 40bd01be5c25
children f89f83c8393a
comparison
equal deleted inserted replaced
29063:8ede973597fd 29067:207c0db08953
40 raise basestore.StoreError(filename, hash, self.url, 40 raise basestore.StoreError(filename, hash, self.url,
41 _("can't get file locally")) 41 _("can't get file locally"))
42 with open(path, 'rb') as fd: 42 with open(path, 'rb') as fd:
43 return lfutil.copyandhash(fd, tmpfile) 43 return lfutil.copyandhash(fd, tmpfile)
44 44
45 def _verifyfile(self, cctx, cset, contents, standin, verified): 45 def _verifyfiles(self, contents, filestocheck):
46 filename = lfutil.splitstandin(standin) 46 failed = False
47 if not filename: 47 for cset, filename, expectedhash in filestocheck:
48 return False 48 storepath, exists = lfutil.findstorepath(self.remote, expectedhash)
49 fctx = cctx[standin] 49 if not exists:
50 key = (filename, fctx.filenode())
51 if key in verified:
52 return False
53
54 expecthash = fctx.data()[0:40]
55 storepath, exists = lfutil.findstorepath(self.remote, expecthash)
56 verified.add(key)
57 if not exists:
58 self.ui.warn(
59 _('changeset %s: %s references missing %s\n')
60 % (cset, filename, storepath))
61 return True # failed
62
63 if contents:
64 actualhash = lfutil.hashfile(storepath)
65 if actualhash != expecthash:
66 self.ui.warn( 50 self.ui.warn(
67 _('changeset %s: %s references corrupted %s\n') 51 _('changeset %s: %s references missing %s\n')
68 % (cset, filename, storepath)) 52 % (cset, filename, storepath))
69 return True # failed 53 failed = True
70 return False 54 elif contents:
55 actualhash = lfutil.hashfile(storepath)
56 if actualhash != expectedhash:
57 self.ui.warn(
58 _('changeset %s: %s references corrupted %s\n')
59 % (cset, filename, storepath))
60 failed = True
61 return failed