diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-12-06 16:19:36 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-12-06 16:40:16 +0100 |
commit | 4523f153cd37fe54f7e88214cfaedb94d078fa46 (patch) | |
tree | 07ffb3da205475c7009b447164eb3452b1cd1dfd /obnamlib/plugins/restore_plugin.py | |
parent | 94803f3ebd6d13e56469e025ae5414658566bc42 (diff) | |
download | obnam-4523f153cd37fe54f7e88214cfaedb94d078fa46.tar.gz |
Don't compute whole-file MD5 unless allowed
Diffstat (limited to 'obnamlib/plugins/restore_plugin.py')
-rw-r--r-- | obnamlib/plugins/restore_plugin.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py index 239eef45..f24ac491 100644 --- a/obnamlib/plugins/restore_plugin.py +++ b/obnamlib/plugins/restore_plugin.py @@ -274,7 +274,10 @@ class RestorePlugin(obnamlib.ObnamPlugin): logging.debug('restoring regular %s', filename) if self.write_ok: f = self.fs.open('./' + filename, 'wb') - summer = hashlib.md5() + if obnamlib.REPO_FILE_MD5 in self.repo.get_allowed_file_keys(): + summer = hashlib.md5() + else: + summer = None try: chunkids = self.repo.get_file_chunk_ids(gen, filename) @@ -287,7 +290,7 @@ class RestorePlugin(obnamlib.ObnamPlugin): f.close() correct_checksum = metadata.md5 - if summer.digest() != correct_checksum: + if summer and summer.digest() != correct_checksum: msg = 'File checksum restore error: %s' % filename msg += ' (%s vs %s)' % ( summer.hexdigest(), correct_checksum.encode('hex')) @@ -301,7 +304,8 @@ class RestorePlugin(obnamlib.ObnamPlugin): for chunkid in chunkids: data = self.repo.get_chunk_content(chunkid) self.verify_chunk_checksum(data, chunkid) - checksummer.update(data) + if checksummer: + checksummer.update(data) self.downloaded_bytes += len(data) if len(data) != len(zeroes): zeroes = '\0' * len(data) |