rdiff-backup-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/Rdiff.py


From: Ben Escoto
Subject: [Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/Rdiff.py
Date: Thu, 27 Oct 2005 02:16:40 -0400

Index: rdiff-backup/rdiff_backup/Rdiff.py
diff -u rdiff-backup/rdiff_backup/Rdiff.py:1.12 
rdiff-backup/rdiff_backup/Rdiff.py:1.13
--- rdiff-backup/rdiff_backup/Rdiff.py:1.12     Thu Aug 18 04:12:54 2005
+++ rdiff-backup/rdiff_backup/Rdiff.py  Thu Oct 27 06:16:39 2005
@@ -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 @@
                        (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_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 @@
        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"""




reply via email to

[Prev in Thread] Current Thread [Next in Thread]