From 9da6efdb9f5a84a4463e1587d5c02b19c9c7a17a Mon Sep 17 00:00:00 2001 From: bescoto Date: Sun, 28 Sep 2003 18:36:51 +0000 Subject: Mostly another unreadable regress fix git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@463 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/regress.py | 22 +++++++++------------- rdiff-backup/rdiff_backup/rpath.py | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'rdiff-backup/rdiff_backup') diff --git a/rdiff-backup/rdiff_backup/regress.py b/rdiff-backup/rdiff_backup/regress.py index b508138..acee41f 100644 --- a/rdiff-backup/rdiff_backup/regress.py +++ b/rdiff-backup/rdiff_backup/regress.py @@ -114,27 +114,23 @@ def remove_rbdir_increments(): def iterate_raw_rfs(mirror_rp, inc_rp): """Iterate all RegressFile objects in mirror/inc directory - Also changes permissions of unreadable files to allow access and - then changes them back later. + Also changes permissions of unreadable files. We don't have to + change them back later because regress will do that for us. """ root_rf = RegressFile(mirror_rp, inc_rp, restore.get_inclist(inc_rp)) def helper(rf): mirror_rp = rf.mirror_rp - if (Globals.process_uid != 0 and - ((mirror_rp.isreg() and not mirror_rp.readable()) or - (mirror_rp.isdir() and not mirror_rp.hasfullperms()))): - unreadable, old_perms = 1, mirror_rp.getperms() - if mirror_rp.isreg(): mirror_rp.chmod(0400 | old_perms) - else: mirror_rp.chmod(0700 | old_perms) - else: unreadable = 0 + if Globals.process_uid != 0: + if mirror_rp.isreg() and not mirror_rp.readable(): + mirror_rp.chmod(0400 | mirror_rp.getperms()) + elif mirror_rp.isdir() and not mirror_rp.hasfullperms(): + mirror_rp.chmod(0700 | mirror_rp.getperms()) yield rf - if unreadable and mirror_rp.isreg(): mirror_rp.chmod(old_perms) if rf.mirror_rp.isdir() or rf.inc_rp.isdir(): for sub_rf in rf.yield_sub_rfs(): for sub_sub_rf in helper(sub_rf): yield sub_sub_rf - if unreadable and mirror_rp.isdir(): mirror_rp.chmod(old_perms) return helper(root_rf) def yield_metadata(): @@ -248,14 +244,14 @@ class RegressITRB(rorpiter.ITRBranch): if rf.mirror_rp.isreg(): tf = TempFile.new(rf.mirror_rp) tf.write_from_fileobj(rf.get_restore_fp()) - rpath.copy_attribs(rf.metadata_rorp, tf) tf.fsync_with_dir() # make sure tf fully written before move + rpath.copy_attribs(rf.metadata_rorp, tf) rpath.rename(tf, rf.mirror_rp) # move is atomic else: if rf.mirror_rp.lstat(): rf.mirror_rp.delete() rf.mirror_rp.write_from_fileobj(rf.get_restore_fp()) rpath.copy_attribs(rf.metadata_rorp, rf.mirror_rp) - rf.mirror_rp.fsync_with_dir() # require move before inc delete + rf.mirror_rp.get_parent_rp().fsync() # require move before inc delete def start_process(self, index, rf): """Start processing directory""" diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index a834c5c..1786dd8 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -151,7 +151,7 @@ def copy_attribs(rpin, rpout): """ log.Log("Copying attributes from %s to %s" % (rpin.index, rpout.path), 7) - assert rpin.lstat() == rpout.lstat() is not None, "different file types" + assert rpin.lstat() == rpout.lstat() or rpin.isspecial() if rpin.issym(): return # symlinks have no valid attributes if Globals.write_resource_forks and rpin.isreg(): rpout.write_resource_fork(rpin.get_resource_fork()) -- cgit v1.2.1