Commit 73744ae5 authored by dgaudet's avatar dgaudet

Preserve Mac OS X 'Creation Date' field across backups. (Patch from Andrew

Ferguson.)


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@759 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 8bdd6f89
New in v1.1.6 (????/??/??) 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.) Set symlink permissions properly. (Patch from Andrew Ferguson.)
Selection fix: empty directories could sometimes be improperly Selection fix: empty directories could sometimes be improperly
......
...@@ -70,6 +70,7 @@ def carbonfile2string(cfile): ...@@ -70,6 +70,7 @@ def carbonfile2string(cfile):
retvalparts.append('type:%s' % binascii.hexlify(cfile['type'])) retvalparts.append('type:%s' % binascii.hexlify(cfile['type']))
retvalparts.append('location:%d,%d' % cfile['location']) retvalparts.append('location:%d,%d' % cfile['location'])
retvalparts.append('flags:%d' % cfile['flags']) retvalparts.append('flags:%d' % cfile['flags'])
retvalparts.append('createDate:%d' % cfile['createDate'])
return '|'.join(retvalparts) return '|'.join(retvalparts)
def string2carbonfile(data): def string2carbonfile(data):
...@@ -87,6 +88,8 @@ def string2carbonfile(data): ...@@ -87,6 +88,8 @@ def string2carbonfile(data):
retval['location'] = (int(a), int(b)) retval['location'] = (int(a), int(b))
elif key == 'flags': elif key == 'flags':
retval['flags'] = int(value) retval['flags'] = int(value)
elif key == 'createDate':
retval['createDate'] = int(value)
return retval return retval
def RORP2Record(rorpath): def RORP2Record(rorpath):
......
...@@ -1212,6 +1212,8 @@ class RPath(RORPath): ...@@ -1212,6 +1212,8 @@ class RPath(RORPath):
if not cfile: return if not cfile: return
log.Log("Writing carbon data to %s" % (self.index,), 7) log.Log("Writing carbon data to %s" % (self.index,), 7)
from Carbon.File import FSSpec from Carbon.File import FSSpec
from Carbon.File import FSRef
import Carbon.Files
import MacOS import MacOS
fsobj = FSSpec(self.path) fsobj = FSSpec(self.path)
finderinfo = fsobj.FSpGetFInfo() finderinfo = fsobj.FSpGetFInfo()
...@@ -1220,7 +1222,16 @@ class RPath(RORPath): ...@@ -1220,7 +1222,16 @@ class RPath(RORPath):
finderinfo.Location = cfile['location'] finderinfo.Location = cfile['location']
finderinfo.Flags = cfile['flags'] finderinfo.Flags = cfile['flags']
fsobj.FSpSetFInfo(finderinfo) fsobj.FSpSetFInfo(finderinfo)
"""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) self.set_carbonfile(cfile)
except KeyError: self.set_carbonfile(cfile)
def get_resource_fork(self): def get_resource_fork(self):
"""Return resource fork data, setting if necessary""" """Return resource fork data, setting if necessary"""
...@@ -1342,14 +1353,18 @@ def setdata_local(rpath): ...@@ -1342,14 +1353,18 @@ def setdata_local(rpath):
def carbonfile_get(rpath): def carbonfile_get(rpath):
"""Return carbonfile value for local rpath""" """Return carbonfile value for local rpath"""
from Carbon.File import FSSpec from Carbon.File import FSSpec
from Carbon.File import FSRef
import Carbon.Files
import MacOS import MacOS
try: try:
fsobj = FSSpec(rpath.path) fsobj = FSSpec(rpath.path)
finderinfo = fsobj.FSpGetFInfo() finderinfo = fsobj.FSpGetFInfo()
cataloginfo, d1, d2, d3 = FSRef(fsobj).FSGetCatalogInfo(Carbon.Files.kFSCatInfoCreateDate)
cfile = {'creator': finderinfo.Creator, cfile = {'creator': finderinfo.Creator,
'type': finderinfo.Type, 'type': finderinfo.Type,
'location': finderinfo.Location, 'location': finderinfo.Location,
'flags': finderinfo.Flags} 'flags': finderinfo.Flags,
'createDate': cataloginfo.createDate[1]}
return cfile return cfile
except MacOS.Error: except MacOS.Error:
log.Log("Cannot read carbonfile information from %s" % log.Log("Cannot read carbonfile information from %s" %
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment