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

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

[rdiff-backup-users] Mac OS X Creation Dates support


From: Andrew Ferguson
Subject: [rdiff-backup-users] Mac OS X Creation Dates support
Date: Thu, 17 Aug 2006 17:25:30 -0400
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

Hi,

The attached patch against the rdiff-backup CVS adds support for
preserving the Mac OS X 'Creation Date' field across backups.

The patch works by saving the Creation Date in the rdiff-backup metadata
and then setting it upon file restore. Like with other Mac OS X file
data, it sets the creation date on the backup copy if the underlying
filesystem supports it.

Cheers,
Andrew

-- 
Andrew Ferguson - address@hidden

diff -Nur rdiff-backup-cvs/rdiff_backup/metadata.py 
rdiff-backup-cdates/rdiff_backup/metadata.py
--- rdiff-backup-cvs/rdiff_backup/metadata.py   2006-01-29 17:16:05.000000000 
-0500
+++ rdiff-backup-cdates/rdiff_backup/metadata.py        2006-08-17 
17:10:38.000000000 -0400
@@ -70,6 +70,7 @@
        retvalparts.append('type:%s' % binascii.hexlify(cfile['type']))
        retvalparts.append('location:%d,%d' % cfile['location'])
        retvalparts.append('flags:%d' % cfile['flags'])
+       retvalparts.append('createDate:%d' % cfile['createDate'])
        return '|'.join(retvalparts)
 
 def string2carbonfile(data):
@@ -87,6 +88,8 @@
                        retval['location'] = (int(a), int(b))
                elif key == 'flags':
                        retval['flags'] = int(value)
+               elif key == 'createDate':
+                       retval['createDate'] = int(value)
        return retval
 
 def RORP2Record(rorpath):
diff -Nur rdiff-backup-cvs/rdiff_backup/rpath.py 
rdiff-backup-cdates/rdiff_backup/rpath.py
--- rdiff-backup-cvs/rdiff_backup/rpath.py      2006-01-13 00:29:47.000000000 
-0500
+++ rdiff-backup-cdates/rdiff_backup/rpath.py   2006-08-17 17:09:43.000000000 
-0400
@@ -1207,6 +1207,8 @@
                if not cfile: return
                log.Log("Writing carbon data to %s" % (self.index,), 7)
                from Carbon.File import FSSpec
+               from Carbon.File import FSRef
+               import Carbon.Files
                import MacOS
                fsobj = FSSpec(self.path)
                finderinfo = fsobj.FSpGetFInfo()
@@ -1215,7 +1217,16 @@
                finderinfo.Location = cfile['location']
                finderinfo.Flags = cfile['flags']
                fsobj.FSpSetFInfo(finderinfo)
-               self.set_carbonfile(cfile)
+
+               """Write Creation Date to self (if stored in metadata)."""
+               try:
+                       cdate = cfile['createDate']
+                       fsref = FSRef(fsobj)
+                       cataloginfo, d1, d2, d3 = 
fsref.FSGetCatalogInfo(Carbon.Files.kFSCatInfoCreateDate)
+                       cataloginfo.createDate = (0, cdate, 0)
+                       
fsref.FSSetCatalogInfo(Carbon.Files.kFSCatInfoCreateDate, cataloginfo)
+                       self.set_carbonfile(cfile)
+               except KeyError: self.set_carbonfile(cfile)
 
        def get_resource_fork(self):
                """Return resource fork data, setting if necessary"""
@@ -1337,14 +1348,18 @@
 def carbonfile_get(rpath):
        """Return carbonfile value for local rpath"""
        from Carbon.File import FSSpec
+       from Carbon.File import FSRef
+       import Carbon.Files
        import MacOS
        try:
                fsobj = FSSpec(rpath.path)
                finderinfo = fsobj.FSpGetFInfo()
+               cataloginfo, d1, d2, d3 = 
FSRef(fsobj).FSGetCatalogInfo(Carbon.Files.kFSCatInfoCreateDate)
                cfile = {'creator': finderinfo.Creator,
                                 'type': finderinfo.Type,
                                 'location': finderinfo.Location,
-                                'flags': finderinfo.Flags}
+                                'flags': finderinfo.Flags,
+                                'createDate': cataloginfo.createDate[1]}
                return cfile
        except MacOS.Error:
                log.Log("Cannot read carbonfile information from %s" %

reply via email to

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