diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-17 19:52:41 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-17 20:57:42 +0200 |
commit | dca0e404149ebcecd17e0e57848d69d2ec27ca08 (patch) | |
tree | b85b8ea3449db9ee51e225bb3a668e2e194a1fb2 | |
parent | 200921f67497952516f20a249e8c31e1f5154331 (diff) | |
download | obnam-dca0e404149ebcecd17e0e57848d69d2ec27ca08.tar.gz |
Use whole-file checksummer in backup plugin
-rw-r--r-- | obnamlib/metadata.py | 2 | ||||
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/obnamlib/metadata.py b/obnamlib/metadata.py index 9f2e46b4..11e3449a 100644 --- a/obnamlib/metadata.py +++ b/obnamlib/metadata.py @@ -34,7 +34,7 @@ metadata_verify_fields = ( ) metadata_fields = metadata_verify_fields + ( 'st_blocks', 'st_dev', 'st_gid', 'st_ino', 'st_atime_sec', - 'st_atime_nsec', 'md5', 'test', + 'st_atime_nsec', 'md5', 'whole_file_checksum', 'test', ) diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 29512ad3..c263483f 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -727,10 +727,8 @@ class BackupPlugin(obnamlib.ObnamPlugin): tracing.trace('opening file for reading') f = self.fs.open(filename, 'r') - if obnamlib.REPO_FILE_MD5 in self.repo.get_allowed_file_keys(): - summer = hashlib.md5() - else: - summer = None + checksum_key = self.repo.get_client_checksum_key(self.client_name) + whole_file_summer = obnamlib.WholeFileCheckSummer(checksum_key) chunk_size = int(self.app.settings['chunk-size']) while True: @@ -742,12 +740,11 @@ class BackupPlugin(obnamlib.ObnamPlugin): break tracing.trace('got %d bytes of data' % len(data)) self.progress.update_progress_with_scanned(len(data)) - if summer: - summer.update(data) if not self.pretend: chunk_id = self.backup_file_chunk(data) self.repo.append_file_chunk_id( self.new_generation, filename, chunk_id) + whole_file_summer.append_chunk(data, chunk_id) else: self.progress.update_progress_with_upload(len(data)) @@ -762,8 +759,11 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.app.dump_memory_profile('at end of file content backup for %s' % filename) tracing.trace('done backing up file contents') - if summer: - metadata.md5 = summer.digest() + + if checksum_key == obnamlib.REPO_FILE_MD5: + metadata.md5 = whole_file_summer.get_checksum() + else: + metadata.whole_file_checksum = whole_file_summer.get_checksum() def backup_file_chunk(self, data): '''Back up a chunk of data by putting it into the repository.''' |