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/rpath.py


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

Index: rdiff-backup/rdiff_backup/rpath.py
diff -u rdiff-backup/rdiff_backup/rpath.py:1.90 
rdiff-backup/rdiff_backup/rpath.py:1.91
--- rdiff-backup/rdiff_backup/rpath.py:1.90     Mon Oct 24 17:16:05 2005
+++ rdiff-backup/rdiff_backup/rpath.py  Thu Oct 27 06:16:39 2005
@@ -82,7 +82,12 @@
                rpin.delete()
 
 def copy(rpin, rpout, compress = 0):
-       """Copy RPath rpin to rpout.  Works for symlinks, dirs, etc."""
+       """Copy RPath rpin to rpout.  Works for symlinks, dirs, etc.
+
+       Returns close value of input for regular file, which can be used
+       to pass hashes on.
+
+       """
        log.Log("Regular copying %s to %s" % (rpin.index, rpout.path), 6)
        if not rpin.lstat():
                if rpout.lstat(): rpout.delete()
@@ -93,7 +98,7 @@
                        rpout.delete()   # easier to write than compare
                else: return
 
-       if rpin.isreg(): copy_reg_file(rpin, rpout, compress)
+       if rpin.isreg(): return copy_reg_file(rpin, rpout, compress)
        elif rpin.isdir(): rpout.mkdir()
        elif rpin.issym(): rpout.symlink(rpin.readlink())
        elif rpin.ischardev():
@@ -115,7 +120,7 @@
                        rpout.setdata()
                        return
        except AttributeError: pass
-       rpout.write_from_fileobj(rpin.open("rb"), compress = compress)
+       return rpout.write_from_fileobj(rpin.open("rb"), compress = compress)
 
 def cmp(rpin, rpout):
        """True if rpin has the same data as rpout
@@ -349,6 +354,7 @@
                        elif key == 'carbonfile' and not 
Globals.carbonfile_write: pass
                        elif key == 'resourcefork' and not 
Globals.resource_forks_write:
                                pass
+                       elif key == 'sha1': pass # one or other may not have set
                        elif (not other.data.has_key(key) or
                                  self.data[key] != other.data[key]): return 0
 
@@ -646,6 +652,18 @@
                """Record resource fork in dictionary.  Does not write"""
                self.data['resourcefork'] = rfork
 
+       def has_sha1(self):
+               """True iff self has its sha1 digest set"""
+               return self.data.has_key('sha1')
+
+       def get_sha1(self):
+               """Return sha1 digest.  Causes exception unless set_sha1 
first"""
+               return self.data['sha1']
+
+       def set_sha1(self, digest):
+               """Set sha1 hash (should be in hexdecimal)"""
+               self.data['sha1'] = digest
+
 
 class RPath(RORPath):
        """Remote Path class - wrapper around a possibly non-local pathname
@@ -978,16 +996,16 @@
                """Reads fp and writes to self.path.  Closes both when done
 
                If compress is true, fp will be gzip compressed before being
-               written to self.
+               written to self.  Returns closing value of fp.
 
                """
                log.Log("Writing file object to " + self.path, 7)
                assert not self.lstat(), "File %s already exists" % self.path
                outfp = self.open("wb", compress = compress)
                copyfileobj(fp, outfp)
-               if fp.close() or outfp.close():
-                       raise RPathException("Error closing file")
+               if outfp.close(): raise RPathException("Error closing file")
                self.setdata()
+               return fp.close()
 
        def write_string(self, s, compress = None):
                """Write string s into rpath"""




reply via email to

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