| 185 | raise FileIntegrityError(path) |
| 186 | |
| 187 | def hash_part(self, partname, is_final=False): |
| 188 | if not self.writing and not self.digests: |
| 189 | return |
| 190 | self.hasher.update(("%10d" % len(partname)).encode()) |
| 191 | self.hasher.update(partname.encode()) |
| 192 | self.hasher.hash_length(seek_to_end=is_final) |
| 193 | digest = self.hasher.hexdigest() |
| 194 | if self.writing: |
| 195 | self.digests[partname] = digest |
| 196 | elif self.digests and not compare_digest(self.digests.get(partname, ""), digest): |
| 197 | raise FileIntegrityError(self.path) |
| 198 | |
| 199 | def __exit__(self, exc_type, exc_val, exc_tb): |
| 200 | exception = exc_type is not None |