Commit d8bddb3f authored by bescoto's avatar bescoto

Make no preserve hard links disable inode comparison


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@314 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 33625d02
...@@ -54,7 +54,7 @@ process_gid = os.getgid() ...@@ -54,7 +54,7 @@ process_gid = os.getgid()
change_ownership = None change_ownership = None
# If true, when copying attributes, also change target's permission. # If true, when copying attributes, also change target's permission.
change_permission = 1 change_permissions = 1
# If true, change the permissions of unwriteable mirror files # If true, change the permissions of unwriteable mirror files
# (such as directories) so that they can be written, and then # (such as directories) so that they can be written, and then
......
...@@ -149,7 +149,7 @@ def parse_cmdlineoptions(arglist): ...@@ -149,7 +149,7 @@ def parse_cmdlineoptions(arglist):
Globals.set('quoting_enabled', 1) Globals.set('quoting_enabled', 1)
Globals.set('preserve_hardlinks', 0) Globals.set('preserve_hardlinks', 0)
Globals.set('change_ownership', 0) Globals.set('change_ownership', 0)
Globals.set('change_permission', 0) Globals.set('change_permissions', 0)
Globals.set('fsync_directories', 0) Globals.set('fsync_directories', 0)
else: Log.FatalError("Unknown option %s" % opt) else: Log.FatalError("Unknown option %s" % opt)
...@@ -288,7 +288,7 @@ def backup_init_dirs(rpin, rpout): ...@@ -288,7 +288,7 @@ def backup_init_dirs(rpin, rpout):
if rpout.lstat(): if rpout.lstat():
if rpout.isdir() and not rpout.listdir(): # rpout is empty dir if rpout.isdir() and not rpout.listdir(): # rpout is empty dir
if Globals.change_permission: if Globals.change_permissions:
rpout.chmod(0700) # just make sure permissions aren't too lax rpout.chmod(0700) # just make sure permissions aren't too lax
elif not datadir.lstat() and not force: Log.FatalError( elif not datadir.lstat() and not force: Log.FatalError(
"""Destination directory """Destination directory
......
...@@ -468,7 +468,7 @@ class PatchITRB(rorpiter.ITRBranch): ...@@ -468,7 +468,7 @@ class PatchITRB(rorpiter.ITRBranch):
self.dir_replacement) self.dir_replacement)
success = 0 success = 0
else: success = 1 else: success = 1
if base_rp.isdir() and Globals.change_permission: base_rp.chmod(0700) if base_rp.isdir() and Globals.change_permissions: base_rp.chmod(0700)
return success return success
def prepare_dir(self, diff_rorp, base_rp): def prepare_dir(self, diff_rorp, base_rp):
...@@ -481,7 +481,7 @@ class PatchITRB(rorpiter.ITRBranch): ...@@ -481,7 +481,7 @@ class PatchITRB(rorpiter.ITRBranch):
else: # maybe no change, so query CCPP before tagging success else: # maybe no change, so query CCPP before tagging success
if self.CCPP.in_cache(diff_rorp.index): if self.CCPP.in_cache(diff_rorp.index):
self.CCPP.flag_success(diff_rorp.index) self.CCPP.flag_success(diff_rorp.index)
if Globals.change_permission: base_rp.chmod(0700) if Globals.change_permissions: base_rp.chmod(0700)
def end_process(self): def end_process(self):
"""Finish processing directory""" """Finish processing directory"""
......
...@@ -34,7 +34,8 @@ recovered. ...@@ -34,7 +34,8 @@ recovered.
""" """
from __future__ import generators from __future__ import generators
import Globals, restore, log, rorpiter, TempFile, metadata, rpath, C, Time import Globals, restore, log, rorpiter, TempFile, metadata, rpath, C, \
Time, backup
# regress_time should be set to the time we want to regress back to # regress_time should be set to the time we want to regress back to
# (usually the time of the last successful backup) # (usually the time of the last successful backup)
...@@ -211,7 +212,10 @@ class RegressITRB(rorpiter.ITRBranch): ...@@ -211,7 +212,10 @@ class RegressITRB(rorpiter.ITRBranch):
if rf.metadata_rorp.isreg(): self.restore_orig_regfile(rf) if rf.metadata_rorp.isreg(): self.restore_orig_regfile(rf)
else: else:
if rf.mirror_rp.lstat(): rf.mirror_rp.delete() if rf.mirror_rp.lstat(): rf.mirror_rp.delete()
rpath.copy_with_attribs(rf.metadata_rorp, rf.mirror_rp) if diff_rorp.isspecial():
robust.check_common_error(None, rpath.copy_with_attribs,
(rf.metadata_rorp, rf.mirror_rp))
else: rpath.copy_with_attribs(rf.metadata_rorp, rf.mirror_rp)
if rf.regress_inc: if rf.regress_inc:
log.Log("Deleting increment " + rf.regress_inc.path, 5) log.Log("Deleting increment " + rf.regress_inc.path, 5)
rf.regress_inc.delete() rf.regress_inc.delete()
...@@ -244,7 +248,7 @@ class RegressITRB(rorpiter.ITRBranch): ...@@ -244,7 +248,7 @@ class RegressITRB(rorpiter.ITRBranch):
if not rf.mirror_rp.isdir(): if not rf.mirror_rp.isdir():
if rf.mirror_rp.lstat(): rf.mirror_rp.delete() if rf.mirror_rp.lstat(): rf.mirror_rp.delete()
rf.mirror_rp.mkdir() rf.mirror_rp.mkdir()
if Globals.change_permission and not rf.mirror_rp.hasfullperms(): if Globals.change_permissions and not rf.mirror_rp.hasfullperms():
rf.mirror_rp.chmod(0700) rf.mirror_rp.chmod(0700)
self.rf = rf self.rf = rf
......
...@@ -532,7 +532,7 @@ class PatchITRB(rorpiter.ITRBranch): ...@@ -532,7 +532,7 @@ class PatchITRB(rorpiter.ITRBranch):
assert diff_rorp.get_attached_filetype() == 'snapshot' assert diff_rorp.get_attached_filetype() == 'snapshot'
self.dir_replacement = TempFile.new(base_rp) self.dir_replacement = TempFile.new(base_rp)
rpath.copy_with_attribs(diff_rorp, self.dir_replacement) rpath.copy_with_attribs(diff_rorp, self.dir_replacement)
if base_rp.isdir() and Globals.change_permission: base_rp.chmod(0700) if base_rp.isdir() and Globals.change_permissions: base_rp.chmod(0700)
def prepare_dir(self, diff_rorp, base_rp): def prepare_dir(self, diff_rorp, base_rp):
"""Prepare base_rp to turn into a directory""" """Prepare base_rp to turn into a directory"""
...@@ -540,7 +540,7 @@ class PatchITRB(rorpiter.ITRBranch): ...@@ -540,7 +540,7 @@ class PatchITRB(rorpiter.ITRBranch):
if not base_rp.isdir(): if not base_rp.isdir():
if base_rp.lstat(): base_rp.delete() if base_rp.lstat(): base_rp.delete()
base_rp.mkdir() base_rp.mkdir()
if Globals.change_permission: base_rp.chmod(0700) if Globals.change_permissions: base_rp.chmod(0700)
def end_process(self): def end_process(self):
"""Finish processing directory""" """Finish processing directory"""
......
...@@ -157,7 +157,7 @@ def copy_attribs(rpin, rpout): ...@@ -157,7 +157,7 @@ def copy_attribs(rpin, rpout):
check_for_files(rpin, rpout) check_for_files(rpin, rpout)
if rpin.issym(): return # symlinks have no valid attributes if rpin.issym(): return # symlinks have no valid attributes
if Globals.change_ownership: apply(rpout.chown, rpin.getuidgid()) if Globals.change_ownership: apply(rpout.chown, rpin.getuidgid())
if Globals.change_permission: rpout.chmod(rpin.getperms()) if Globals.change_permissions: rpout.chmod(rpin.getperms())
if not rpin.isdev(): rpout.setmtime(rpin.getmtime()) if not rpin.isdev(): rpout.setmtime(rpin.getmtime())
def cmp_attribs(rp1, rp2): def cmp_attribs(rp1, rp2):
...@@ -266,12 +266,14 @@ class RORPath: ...@@ -266,12 +266,14 @@ class RORPath:
if (key == 'uid' or key == 'gid') and self.issym(): if (key == 'uid' or key == 'gid') and self.issym():
# Don't compare gid/uid for symlinks # Don't compare gid/uid for symlinks
pass pass
elif key == 'perms' and not Globals.change_permissions: pass
elif key == 'atime' and not Globals.preserve_atime: pass elif key == 'atime' and not Globals.preserve_atime: pass
elif key == 'devloc' or key == 'nlink': pass elif key == 'devloc' or key == 'nlink': pass
elif key == 'size' and not self.isreg(): pass elif key == 'size' and not self.isreg(): pass
elif (key == 'inode' and elif (key == 'inode' and
(not self.isreg() or self.getnumlinks() == 1 or (not self.isreg() or self.getnumlinks() == 1 or
not Globals.compare_inode)): pass not Globals.compare_inode or
not Globals.preserve_hardlinks)): pass
elif (not other.data.has_key(key) or elif (not other.data.has_key(key) or
self.data[key] != other.data[key]): return None self.data[key] != other.data[key]): return None
return 1 return 1
...@@ -298,6 +300,7 @@ class RORPath: ...@@ -298,6 +300,7 @@ class RORPath:
elif key == 'atime' and not Globals.preserve_atime: pass elif key == 'atime' and not Globals.preserve_atime: pass
elif key == 'devloc' or key == 'nlink': pass elif key == 'devloc' or key == 'nlink': pass
elif key == 'size' and not self.isreg(): pass elif key == 'size' and not self.isreg(): pass
elif key == 'perms' and not Globals.change_permissions: pass
elif key == 'inode': pass elif key == 'inode': pass
elif (not other.data.has_key(key) or elif (not other.data.has_key(key) or
self.data[key] != other.data[key]): return 0 self.data[key] != other.data[key]): return 0
...@@ -315,6 +318,7 @@ class RORPath: ...@@ -315,6 +318,7 @@ class RORPath:
(self.issym() or not compare_ownership)): (self.issym() or not compare_ownership)):
# Don't compare gid/uid for symlinks, or if told not to # Don't compare gid/uid for symlinks, or if told not to
pass pass
elif key == 'perms' and not Globals.change_permissions: pass
elif key == 'atime' and not Globals.preserve_atime: pass elif key == 'atime' and not Globals.preserve_atime: pass
elif key == 'devloc' or key == 'nlink': pass elif key == 'devloc' or key == 'nlink': pass
elif key == 'size' and not self.isreg(): pass elif key == 'size' and not self.isreg(): pass
......
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