summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/Rdiff.py
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-10-27 06:16:39 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-10-27 06:16:39 +0000
commitd9b68d73175d004caed8c781c97308f7c2e3dccc (patch)
tree7be1e3b4c7a23324d6d4ef0ed5483b890ee58210 /rdiff-backup/rdiff_backup/Rdiff.py
parent80470345fa1998a033078314f77930a60ea14107 (diff)
downloadrdiff-backup-d9b68d73175d004caed8c781c97308f7c2e3dccc.tar.gz
Write SHA1 digests for all regular files
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@662 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/Rdiff.py')
-rw-r--r--rdiff-backup/rdiff_backup/Rdiff.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/rdiff-backup/rdiff_backup/Rdiff.py b/rdiff-backup/rdiff_backup/Rdiff.py
index 5428e19..f183141 100644
--- a/rdiff-backup/rdiff_backup/Rdiff.py
+++ b/rdiff-backup/rdiff_backup/Rdiff.py
@@ -1,4 +1,4 @@
-# Copyright 2002 Ben Escoto
+# Copyright 2002 2005 Ben Escoto
#
# This file is part of rdiff-backup.
#
@@ -20,7 +20,7 @@
"""Invoke rdiff utility to make signatures, deltas, or patch"""
import os, librsync
-import Globals, log, static, TempFile, rpath
+import Globals, log, static, TempFile, rpath, hash
def get_signature(rp, blocksize = None):
@@ -53,6 +53,14 @@ def get_delta_sigrp(rp_signature, rp_new):
(rp_new.path, rp_signature.get_indexpath()), 7)
return librsync.DeltaFile(rp_signature.open("rb"), rp_new.open("rb"))
+def get_delta_sigrp_hash(rp_signature, rp_new):
+ """Like above but also calculate hash of new as close() value"""
+ log.Log("Getting delta with hash of %s with signature %s" %
+ (rp_new.path, rp_signature.get_indexpath()), 7)
+ return librsync.DeltaFile(rp_signature.open("rb"),
+ hash.FileWrapper(rp_new.open("rb")))
+
+
def write_delta(basis, new, delta, compress = None):
"""Write rdiff delta which brings basis to new"""
log.Log("Writing delta %s from %s -> %s" %
@@ -68,8 +76,9 @@ def write_patched_fp(basis_fp, delta_fp, out_fp):
def write_via_tempfile(fp, rp):
"""Write fileobj fp to rp by writing to tempfile and renaming"""
tf = TempFile.new(rp)
- tf.write_from_fileobj(fp)
+ retval = tf.write_from_fileobj(fp)
rpath.rename(tf, rp)
+ return retval
def patch_local(rp_basis, rp_delta, outrp = None, delta_compressed = None):
"""Patch routine that must be run locally, writes to outrp
@@ -83,8 +92,8 @@ def patch_local(rp_basis, rp_delta, outrp = None, delta_compressed = None):
if delta_compressed: deltafile = rp_delta.open("rb", 1)
else: deltafile = rp_delta.open("rb")
patchfile = librsync.PatchedFile(rp_basis.open("rb"), deltafile)
- if outrp: outrp.write_from_fileobj(patchfile)
- else: write_via_tempfile(patchfile, rp_basis)
+ if outrp: return outrp.write_from_fileobj(patchfile)
+ else: return write_via_tempfile(patchfile, rp_basis)
def copy_local(rpin, rpout, rpnew = None):
"""Write rpnew == rpin using rpout as basis. rpout and rpnew local"""