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

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

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

revision 1.52 by bescoto, Tue Nov 1 04:46:16 2005 UTC revision 1.53 by bescoto, Tue Nov 1 16:46:29 2005 UTC
# Line 22  Line 22 
22  from __future__ import generators  from __future__ import generators
23  import tempfile, os, cStringIO  import tempfile, os, cStringIO
24  import Globals, Time, Rdiff, Hardlink, rorpiter, selection, rpath, \  import Globals, Time, Rdiff, Hardlink, rorpiter, selection, rpath, \
25             log, static, robust, metadata, statistics, TempFile, eas_acls             log, static, robust, metadata, statistics, TempFile, eas_acls, hash
26    
27    
28  class RestoreError(Exception): pass  class RestoreError(Exception): pass
# Line 256  class MirrorStruct: Line 256  class MirrorStruct:
256                          mir_rorp.flaglinked(Hardlink.get_link_index(mir_rorp))                          mir_rorp.flaglinked(Hardlink.get_link_index(mir_rorp))
257                  elif mir_rorp.isreg():                  elif mir_rorp.isreg():
258                          expanded_index = cls.mirror_base.index + mir_rorp.index                          expanded_index = cls.mirror_base.index + mir_rorp.index
259                          mir_rorp.setfile(cls.rf_cache.get_fp(expanded_index))                          file_fp = cls.rf_cache.get_fp(expanded_index)
260                            mir_rorp.setfile(hash.FileWrapper(file_fp))
261                  mir_rorp.set_attached_filetype('snapshot')                  mir_rorp.set_attached_filetype('snapshot')
262                  return mir_rorp                  return mir_rorp
263    
# Line 616  class PatchITRB(rorpiter.ITRBranch): Line 617  class PatchITRB(rorpiter.ITRBranch):
617                  self.patch_to_temp(rp, diff_rorp, tf)                  self.patch_to_temp(rp, diff_rorp, tf)
618                  rpath.rename(tf, rp)                  rpath.rename(tf, rp)
619    
620            def check_hash(self, copy_report, diff_rorp):
621                    """Check the hash in the copy_report with hash in diff_rorp"""
622                    if not diff_rorp.isreg(): return
623                    if not diff_rorp.has_sha1():
624                            log.Log("Hash for %s missing, cannot check" %
625                                            (diff_rorp.get_indexpath()), 2)
626                    elif copy_report.sha1_digest == diff_rorp.get_sha1():
627                            log.Log("Hash %s of %s verified" %
628                                            (diff_rorp.get_sha1(), diff_rorp.get_indexpath()), 6)
629                    else:
630                            log.Log("Warning: Hash %s of %s\ndoesn't match recorded hash %s!"
631                                            % (copy_report.sha1_digest, diff_rorp.get_indexpath(),
632                                               diff_rorp.get_sha1()), 2)
633    
634          def patch_to_temp(self, basis_rp, diff_rorp, new):          def patch_to_temp(self, basis_rp, diff_rorp, new):
635                  """Patch basis_rp, writing output in new, which doesn't exist yet"""                  """Patch basis_rp, writing output in new, which doesn't exist yet"""
636                  if diff_rorp.isflaglinked():                  if diff_rorp.isflaglinked():
637                          Hardlink.link_rp(diff_rorp, new, self.basis_root_rp)                          Hardlink.link_rp(diff_rorp, new, self.basis_root_rp)
638                  elif diff_rorp.get_attached_filetype() == 'snapshot':                          return
639                          rpath.copy(diff_rorp, new)                  if diff_rorp.get_attached_filetype() == 'snapshot':
640                            copy_report = rpath.copy(diff_rorp, new)
641                  else:                  else:
642                          assert diff_rorp.get_attached_filetype() == 'diff'                          assert diff_rorp.get_attached_filetype() == 'diff'
643                          Rdiff.patch_local(basis_rp, diff_rorp, new)                          copy_report = Rdiff.patch_local(basis_rp, diff_rorp, new)
644                    self.check_hash(copy_report, diff_rorp)
645                  if new.lstat(): rpath.copy_attribs(diff_rorp, new)                  if new.lstat(): rpath.copy_attribs(diff_rorp, new)
646    
647          def start_process(self, index, diff_rorp):          def start_process(self, index, diff_rorp):

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53

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