From f7dc50b215eb22a7b50b17687f92b20f7d629f41 Mon Sep 17 00:00:00 2001 From: dgaudet Date: Sun, 5 Nov 2006 01:24:52 +0000 Subject: Preserve Mac OS X 'Creation Date' field across backups. (Patch from Andrew Ferguson.) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@759 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 3 +++ rdiff-backup/rdiff_backup/metadata.py | 3 +++ rdiff-backup/rdiff_backup/rpath.py | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 42da38d..bda8df0 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,9 @@ New in v1.1.6 (????/??/??) -------------------------- +Preserve Mac OS X 'Creation Date' field across backups. (Patch from Andrew +Ferguson.) + Set symlink permissions properly. (Patch from Andrew Ferguson.) Selection fix: empty directories could sometimes be improperly diff --git a/rdiff-backup/rdiff_backup/metadata.py b/rdiff-backup/rdiff_backup/metadata.py index a96d2e0..2a28281 100644 --- a/rdiff-backup/rdiff_backup/metadata.py +++ b/rdiff-backup/rdiff_backup/metadata.py @@ -70,6 +70,7 @@ def carbonfile2string(cfile): 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 @@ def string2carbonfile(data): 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 --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index 0b527b5..6e77e24 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -1212,6 +1212,8 @@ class RPath(RORPath): 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() @@ -1220,7 +1222,16 @@ class RPath(RORPath): 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""" @@ -1342,14 +1353,18 @@ def setdata_local(rpath): 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" % -- cgit v1.2.1