diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-10-31 04:53:31 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-10-31 04:53:31 +0000 |
commit | a5c03feacbbd9361eb3e2abe367b75529c83459b (patch) | |
tree | bcb8f86bf8cfc61bd771b6e45d557bdda7604e80 /rdiff-backup/rdiff_backup/hash.py | |
parent | a2705f514b471e2b74c98a0cde588863e3ff22c6 (diff) | |
download | rdiff-backup-a5c03feacbbd9361eb3e2abe367b75529c83459b.tar.gz |
Added various compare options like --compare-full and --compare-hash
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@664 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/hash.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/hash.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rdiff-backup/rdiff_backup/hash.py b/rdiff-backup/rdiff_backup/hash.py index 4fcbdab..3e7306f 100644 --- a/rdiff-backup/rdiff_backup/hash.py +++ b/rdiff-backup/rdiff_backup/hash.py @@ -20,6 +20,7 @@ """Contains a file wrapper that returns a hash on close""" import sha +import Globals class FileWrapper: """Wrapper around a file-like object @@ -51,3 +52,17 @@ class Report: def __init__(self, close_val, sha1_digest): assert not close_val # For now just assume inner file closes correctly self.sha1_digest = sha1_digest + + +def compute_sha1(rp, compressed = 0): + """Return the hex sha1 hash of given rpath""" + assert rp.conn is Globals.local_connection # inefficient not to do locally + blocksize = Globals.blocksize + fp = FileWrapper(rp.open("r", compressed)) + while 1: + if not fp.read(blocksize): break + digest = fp.close().sha1_digest + rp.set_sha1(digest) + return digest + + |