Commit 1fc70b9b authored by bescoto's avatar bescoto

May have fixed recursion bug in resource forks; added another test


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@348 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent e916e92d
......@@ -1021,13 +1021,16 @@ class RPath(RORPath):
assert self.isreg()
try: rfork = self.data['resourcefork']
except KeyError:
rfork = self.append('rsrc').get_data()
rfork_fp = self.conn.open(os.path.join(self.path, 'rsrc'), 'rb')
rfork = rfork_fp.read()
assert not rfork_fp.close()
self.data['resourcefork'] = rfork
return rfork
def write_resource_fork(self, rfork_data):
"""Write new resource fork to self"""
fp = self.append('rsrc').open('wb')
log.Log("Writing resource fork to %s" % (self.index,), 7)
fp = self.conn.open(os.path.join(self.path, 'rsrc'), 'wb')
fp.write(rfork_data)
assert not fp.close()
......
......@@ -14,8 +14,11 @@ Globals.read_resource_forks = Globals.write_resource_forks = 1
class ResourceForkTest(unittest.TestCase):
"""Test dealing with Mac OS X style resource forks"""
tempdir = rpath.RPath(Globals.local_connection,
'testfiles/resource_fork_test')
tempdir = rpath.RPath(Globals.local_connection, 'testfiles/output')
rf_testdir1 = rpath.RPath(Globals.local_connection,
'testfiles/resource_fork_test1')
rf_testdir2 = rpath.RPath(Globals.local_connection,
'testfiles/resource_fork_test2')
def make_temp(self):
"""Make temp directory testfiles/resource_fork_test"""
if self.tempdir.lstat(): self.tempdir.delete()
......@@ -49,5 +52,51 @@ class ResourceForkTest(unittest.TestCase):
assert rorp_out == rp, (rorp_out, rp)
assert rorp_out.get_resource_fork() == 'hello'
def make_backup_dirs(self):
"""Create testfiles/resource_fork_test[12] dirs for testing"""
if self.rf_testdir1.lstat(): self.rf_testdir1.delete()
if self.rf_testdir2.lstat(): self.rf_testdir2.delete()
self.rf_testdir1.mkdir()
rp1_1 = self.rf_testdir1.append('1')
rp1_2 = self.rf_testdir1.append('2')
rp1_3 = self.rf_testdir1.append('3')
rp1_1.touch()
rp1_2.touch()
rp1_3.symlink('foo')
rp1_1.write_resource_fork('This should appear in resource fork')
rp1_2.write_resource_fork('Data for the resource fork 2')
self.rf_testdir2.mkdir()
rp2_1 = self.rf_testdir2.append('1')
rp2_2 = self.rf_testdir2.append('2')
rp2_3 = self.rf_testdir2.append('3')
rp2_1.touch()
rp2_2.touch()
rp2_3.touch()
rp2_1.write_resource_fork('New data for resource fork 1')
rp2_3.write_resource_fork('New fork')
def testSeriesLocal(self):
"""Test backing up and restoring directories with ACLs locally"""
Globals.read_resource_forks = Globals.write_resource_forks = 1
self.make_backup_dirs()
dirlist = ['testfiles/resource_fork_test1', 'testfiles/empty',
'testfiles/resource_fork_test2',
'testfiles/resource_fork_test1']
# BackupRestoreSeries(1, 1, dirlist, compare_resource_forks = 1)
BackupRestoreSeries(1, 1, dirlist)
def testSeriesRemote(self):
"""Test backing up and restoring directories with ACLs locally"""
Globals.read_resource_forks = Globals.write_resource_forks = 1
self.make_backup_dirs()
dirlist = ['testfiles/resource_fork_test1',
'testfiles/resource_fork_test2', 'testfiles/empty',
'testfiles/resource_fork_test1']
# BackupRestoreSeries(1, 1, dirlist, compare_resource_forks = 1)
BackupRestoreSeries(1, 1, dirlist)
if __name__ == "__main__": unittest.main()
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