|
|
@@ -47,7 +47,10 @@ class Storage: |
|
|
|
# get length |
|
|
|
sz = length |
|
|
|
piececnt = roundup(sz, piecelen) |
|
|
|
self._pieceindex = [ [ dict(file=self._rootpath, offset=x * piecelen, size=piecelen if x < piececnt - 1 else sz - piececnt * x) ] for x in range(piececnt) ] |
|
|
|
self._pieceindex = [ [ dict(file=self._rootpath, |
|
|
|
offset=x * piecelen, size=piecelen if |
|
|
|
x < piececnt - 1 else sz - x * piecelen) ] for x in |
|
|
|
range(piececnt) ] |
|
|
|
else: |
|
|
|
self._buildindex() |
|
|
|
|
|
|
@@ -391,6 +394,18 @@ class _TestCases(unittest.TestCase): |
|
|
|
self.assertFalse(good) |
|
|
|
self.assertEqual(hashes, {}) |
|
|
|
|
|
|
|
shutil.copy(self.fixtures / '40plus1.txt.torrent', self.basetempdir) |
|
|
|
tor = self.basetempdir / '40plus1.txt.torrent' |
|
|
|
|
|
|
|
with open(sd / '40plus1.txt', 'w') as fp: |
|
|
|
fp.write('w') |
|
|
|
|
|
|
|
good, bad, hashes = validate_file(tor, with_file_hashes=sha512) |
|
|
|
|
|
|
|
self.assertEqual(bad, { sd / '40plus1.txt' }) |
|
|
|
self.assertFalse(good) |
|
|
|
self.assertEqual(hashes, {}) |
|
|
|
|
|
|
|
def test_verification(self): |
|
|
|
# Testing for "missing" files |
|
|
|
# piece size 2 (aka 4 bytes) |
|
|
|