summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2006-11-05 01:24:52 +0000
committerdgaudet <dgaudet@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2006-11-05 01:24:52 +0000
commitf7dc50b215eb22a7b50b17687f92b20f7d629f41 (patch)
tree4b7bd25893b4f67b9eb92538170934a4e6a6265e
parent4363435f2a366add774059111a1e405c6f700d76 (diff)
downloadrdiff-backup-f7dc50b215eb22a7b50b17687f92b20f7d629f41.tar.gz
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
-rw-r--r--rdiff-backup/CHANGELOG3
-rw-r--r--rdiff-backup/rdiff_backup/metadata.py3
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py19
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" %