/[rdiff-backup]/rdiff-backup/rdiff_backup/rpath.py
ViewVC logotype

Diff of /rdiff-backup/rdiff_backup/rpath.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.87 by bescoto, Wed Oct 19 02:27:30 2005 UTC revision 1.88 by bescoto, Thu Oct 20 19:34:51 2005 UTC
# Line 152  def copy_attribs(rpin, rpout): Line 152  def copy_attribs(rpin, rpout):
152          """          """
153          log.Log("Copying attributes from %s to %s" % (rpin.index, rpout.path), 7)          log.Log("Copying attributes from %s to %s" % (rpin.index, rpout.path), 7)
154          assert rpin.lstat() == rpout.lstat() or rpin.isspecial()          assert rpin.lstat() == rpout.lstat() or rpin.isspecial()
155          if Globals.change_ownership: rpout.chown(*user_group.map_rpath(rpin))          if Globals.change_ownership:
156                    rpout.chown(*rpout.conn.user_group.map_rpath(rpin))
157          if rpin.issym(): return # symlinks don't have times or perms          if rpin.issym(): return # symlinks don't have times or perms
158          if Globals.resource_forks_write and rpin.isreg():          if Globals.resource_forks_write and rpin.isreg():
159                  rpout.write_resource_fork(rpin.get_resource_fork())                  rpout.write_resource_fork(rpin.get_resource_fork())
# Line 1068  class RPath(RORPath): Line 1069  class RPath(RORPath):
1069                  if not fp: self.conn.rpath.RPath.fsync_local(self)                  if not fp: self.conn.rpath.RPath.fsync_local(self)
1070                  else: os.fsync(fp.fileno())                  else: os.fsync(fp.fileno())
1071    
1072          def fsync_local(self):          def fsync_local(self, thunk = None):
1073                  """fsync current file, run locally"""                  """fsync current file, run locally
1074    
1075                    If thunk is given, run it before syncing but after gathering
1076                    the file's file descriptor.
1077    
1078                    """
1079                  assert self.conn is Globals.local_connection                  assert self.conn is Globals.local_connection
1080                  fd = os.open(self.path, os.O_RDONLY)                  try:
1081                  os.fsync(fd)                          fd = os.open(self.path, os.O_RDONLY)
1082                  os.close(fd)                          os.fsync(fd)
1083                            os.close(fd)
1084                    except OSError, e:
1085                            if e.errno != errno.EPERM or self.isdir(): raise
1086    
1087                            # Maybe the system doesn't like read-only fsyncing.
1088                            # However, to open RDWR, we may need to alter permissions
1089                            # temporarily.
1090                            if self.hasfullperms(): oldperms = None
1091                            else:
1092                                    oldperms = self.getperms()
1093                                    self.chmod(0700)
1094                            fd = os.open(self.path, os.O_RDWR)
1095                            if oldperms is not None: self.chmod(oldperms)
1096                            if thunk: thunk()
1097                            os.fsync(fd) # Sync after we switch back permissions!
1098                            os.close(fd)
1099    
1100          def fsync_with_dir(self, fp = None):          def fsync_with_dir(self, fp = None):
1101                  """fsync self and directory self is under"""                  """fsync self and directory self is under"""
# Line 1087  class RPath(RORPath): Line 1109  class RPath(RORPath):
1109                  file and the directory to make sure.                  file and the directory to make sure.
1110    
1111                  """                  """
1112                  if self.lstat() and not self.issym():                  if self.lstat() and not self.issym(): self.fsync_local(self.delete)
                         fp = self.open("rb")  
                         self.delete()  
                         os.fsync(fp.fileno())  
                 assert not fp.close()  
1113                  if Globals.fsync_directories: self.get_parent_rp().fsync()                  if Globals.fsync_directories: self.get_parent_rp().fsync()
1114    
1115          def get_data(self):          def get_data(self):
# Line 1224  def setdata_local(rpath): Line 1242  def setdata_local(rpath):
1242                  rpath.get_resource_fork()                  rpath.get_resource_fork()
1243          if Globals.carbonfile_conn and rpath.isreg(): rpath.get_carbonfile()          if Globals.carbonfile_conn and rpath.isreg(): rpath.get_carbonfile()
1244    
1245    
1246  # These two are overwritten by the eas_acls.py module.  We can't  # These two are overwritten by the eas_acls.py module.  We can't
1247  # import that module directly because of circular dependency problems.  # import that module directly because of circular dependency problems.
1248  def acl_get(rp): assert 0  def acl_get(rp): assert 0

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.88

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26