def fast_process(self, index, rf): """Process when nothing is a directory""" if not rf.metadata_rorp.equal_loose(rf.mirror_rp): log.Log("Regressing file %s" % (rf.metadata_rorp.get_indexpath()), 5) if rf.metadata_rorp.isreg(): self.restore_orig_regfile(rf) else: if rf.mirror_rp.lstat(): rf.mirror_rp.delete() if rf.metadata_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: log.Log("Deleting increment " + rf.regress_inc.path, 5) rf.regress_inc.delete()
def set_dir_replacement(self, diff_rorp, base_rp): """Set self.dir_replacement, which holds data until done with dir This is used when base_rp is a dir, and diff_rorp is not. Returns 1 for success or 0 for failure """ assert diff_rorp.get_attached_filetype() == 'snapshot' self.dir_replacement = TempFile.new(base_rp) if not self.patch_to_temp(None, diff_rorp, self.dir_replacement): if self.dir_replacement.lstat(): self.dir_replacement.delete() # Was an error, so now restore original directory rpath.copy_with_attribs(self.CCPP.get_mirror_rorp(diff_rorp.index), self.dir_replacement) return 0 else: return 1
def makesnapshot(mirror, incpref): """Copy mirror to incfile, since new is quite different""" compress = iscompressed(mirror) if compress and mirror.isreg(): snapshotrp = get_inc(incpref, "snapshot.gz") else: snapshotrp = get_inc(incpref, "snapshot") if mirror.isspecial(): # check for errors when creating special increments eh = robust.get_error_handler("SpecialFileError") if robust.check_common_error(eh, rpath.copy_with_attribs, (mirror, snapshotrp, compress)) == 0: snapshotrp.setdata() if snapshotrp.lstat(): snapshotrp.delete() snapshotrp.touch() else: rpath.copy_with_attribs(mirror, snapshotrp, compress) return snapshotrp
def end_process(self): """Finish processing a directory""" rf = self.rf if rf.metadata_rorp.isdir(): if rf.mirror_rp.isdir(): rf.mirror_rp.setdata() if not rf.metadata_rorp.equal_loose(rf.mirror_rp): log.Log("Regressing attributes of " + rf.mirror_rp.path, 5) rpath.copy_attribs(rf.metadata_rorp, rf.mirror_rp) else: rf.mirror_rp.delete() log.Log("Regressing file " + rf.mirror_rp.path, 5) rpath.copy_with_attribs(rf.metadata_rorp, rf.mirror_rp) else: # replacing a dir with some other kind of file assert rf.mirror_rp.isdir() log.Log("Replacing directory " + rf.mirror_rp.path, 5) if rf.metadata_rorp.isreg(): self.restore_orig_regfile(rf) else: rf.mirror_rp.delete() rpath.copy_with_attribs(rf.metadata_rorp, rf.mirror_rp) if rf.regress_inc: log.Log("Deleting increment " + rf.regress_inc.path, 5) rf.regress_inc.delete()