diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-05 03:17:33 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-05-05 03:17:33 +0000 |
commit | 426b4ce41b90e0bf3b49764665e43382326c9375 (patch) | |
tree | 1937cd66bb75c0d7bd7175921dddb80fdcb63e4d /rdiff-backup | |
parent | 525d2c330b2928528f591fdf0fa3cd10fba6a5cf (diff) | |
download | rdiff-backup-426b4ce41b90e0bf3b49764665e43382326c9375.tar.gz |
Various changed to deal with new IterTreeReducer format
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@68 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup')
-rw-r--r-- | rdiff-backup/rdiff_backup/highlevel.py | 37 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/rpath.py | 22 | ||||
-rw-r--r-- | rdiff-backup/src/highlevel.py | 37 | ||||
-rw-r--r-- | rdiff-backup/src/rpath.py | 22 |
4 files changed, 66 insertions, 52 deletions
diff --git a/rdiff-backup/rdiff_backup/highlevel.py b/rdiff-backup/rdiff_backup/highlevel.py index 921f0e1..848cdbe 100644 --- a/rdiff-backup/rdiff_backup/highlevel.py +++ b/rdiff-backup/rdiff_backup/highlevel.py @@ -109,19 +109,19 @@ class HLSourceStruct: """ collated = RORPIter.CollateIterators(cls.initial_dsiter2, sigiter) - finalizer = DestructiveStepping.Finalizer() + finalizer = DestructiveSteppingFinalizer() def diffs(): for dsrp, dest_sig in collated: try: if dest_sig: if dest_sig.isplaceholder(): yield dest_sig else: yield RORPIter.diffonce(dest_sig, dsrp) - if dsrp: finalizer(dsrp) + if dsrp: finalizer(dsrp.index, dsrp) except (IOError, OSError, RdiffException): Log.exception() Log("Error processing %s, skipping" % str(dest_sig.index), 2) - finalizer.getresult() + finalizer.Finish() return diffs() MakeClass(HLSourceStruct) @@ -209,13 +209,15 @@ class HLDestinationStruct: def get_finalizer(cls): """Return finalizer, starting from session info if necessary""" - init_state = cls._session_info and cls._session_info.finalizer_state - return DestructiveStepping.Finalizer(init_state) + old_finalizer = cls._session_info and cls._session_info.finalizer + if old_finalizer: return old_finalizer + else: return DestructiveSteppingFinalizer() def get_ITR(cls, inc_rpath): """Return ITR, starting from state if necessary""" - init_state = cls._session_info and cls._session_info.ITR_state - return Inc.make_patch_increment_ITR(inc_rpath, init_state) + if cls._session_info and cls._session_info.ITR: + return cls._session_info.ITR + else: return IncrementITR(inc_rpath) def patch_and_finalize(cls, dest_rpath, diffs, checkpoint = 1): """Apply diffs and finalize""" @@ -233,7 +235,7 @@ class HLDestinationStruct: DestructiveStepping.initialize(dsrp, None) if diff_rorp and not diff_rorp.isplaceholder(): RORPIter.patchonce_action(None, dsrp, diff_rorp).execute() - finalizer(dsrp) + finalizer(dsrp.index, dsrp) return dsrp try: @@ -242,7 +244,7 @@ class HLDestinationStruct: except StopIteration: break if checkpoint: SaveState.checkpoint_mirror(finalizer, dsrp) except: cls.handle_last_error(dsrp, finalizer) - finalizer.getresult() + finalizer.Finish() if Globals.preserve_hardlinks and Globals.rbdir: Hardlink.final_writedata() if checkpoint: SaveState.checkpoint_remove() @@ -258,16 +260,13 @@ class HLDestinationStruct: indexed_tuple = collated.next() Log("Processing %s" % str(indexed_tuple), 7) diff_rorp, dsrp = indexed_tuple + index = indexed_tuple.index if not dsrp: - dsrp = cls.get_dsrp(dest_rpath, indexed_tuple.index) + dsrp = cls.get_dsrp(dest_rpath, index) DestructiveStepping.initialize(dsrp, None) - indexed_tuple = IndexedTuple(indexed_tuple.index, - (diff_rorp, dsrp)) - if diff_rorp and diff_rorp.isplaceholder(): - indexed_tuple = IndexedTuple(indexed_tuple.index, - (None, dsrp)) - ITR(indexed_tuple) - finalizer(dsrp) + if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None + ITR(index, diff_rorp, dsrp) + finalizer(index, dsrp) return dsrp try: @@ -275,8 +274,8 @@ class HLDestinationStruct: try: dsrp = cls.check_skip_error(error_checked, dsrp) except StopIteration: break SaveState.checkpoint_inc_backup(ITR, finalizer, dsrp) - cls.check_skip_error(ITR.getresult, dsrp) - cls.check_skip_error(finalizer.getresult, dsrp) + cls.check_skip_error(ITR.Finish, dsrp) + cls.check_skip_error(finalizer.Finish, dsrp) except: cls.handle_last_error(dsrp, finalizer, ITR) if Globals.preserve_hardlinks: Hardlink.final_writedata() SaveState.checkpoint_remove() diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index d862951..0089bf6 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -593,13 +593,9 @@ class RPath(RORPath): self.setdata() if not self.lstat(): return # must have been deleted in meantime elif self.isdir(): - def helper(dsrp, base_init_output, branch_reduction): - if dsrp.isdir(): dsrp.rmdir() - else: dsrp.delete() - itm = IterTreeReducer(lambda x: None, lambda x,y: None, None, - helper) - for dsrp in Select(self, None).set_iter(): itm(dsrp) - itm.getresult() + itm = RpathDeleter() + for dsrp in Select(self, None).set_iter(): itm(dsrp.index, dsrp) + itm.Finish() else: self.conn.os.unlink(self.path) self.setdata() @@ -752,3 +748,15 @@ class RPathFileHook: result = self.file.close() self.closing_thunk() return result + + +class RpathDeleter(IterTreeReducer): + """Delete a directory. Called by RPath.delete()""" + def start_process(self, index, dsrp): + self.dsrp = dsrp + + def end_process(self): + if self.dsrp.isdir(): self.dsrp.rmdir() + else: self.dsrp.delete() + + diff --git a/rdiff-backup/src/highlevel.py b/rdiff-backup/src/highlevel.py index 921f0e1..848cdbe 100644 --- a/rdiff-backup/src/highlevel.py +++ b/rdiff-backup/src/highlevel.py @@ -109,19 +109,19 @@ class HLSourceStruct: """ collated = RORPIter.CollateIterators(cls.initial_dsiter2, sigiter) - finalizer = DestructiveStepping.Finalizer() + finalizer = DestructiveSteppingFinalizer() def diffs(): for dsrp, dest_sig in collated: try: if dest_sig: if dest_sig.isplaceholder(): yield dest_sig else: yield RORPIter.diffonce(dest_sig, dsrp) - if dsrp: finalizer(dsrp) + if dsrp: finalizer(dsrp.index, dsrp) except (IOError, OSError, RdiffException): Log.exception() Log("Error processing %s, skipping" % str(dest_sig.index), 2) - finalizer.getresult() + finalizer.Finish() return diffs() MakeClass(HLSourceStruct) @@ -209,13 +209,15 @@ class HLDestinationStruct: def get_finalizer(cls): """Return finalizer, starting from session info if necessary""" - init_state = cls._session_info and cls._session_info.finalizer_state - return DestructiveStepping.Finalizer(init_state) + old_finalizer = cls._session_info and cls._session_info.finalizer + if old_finalizer: return old_finalizer + else: return DestructiveSteppingFinalizer() def get_ITR(cls, inc_rpath): """Return ITR, starting from state if necessary""" - init_state = cls._session_info and cls._session_info.ITR_state - return Inc.make_patch_increment_ITR(inc_rpath, init_state) + if cls._session_info and cls._session_info.ITR: + return cls._session_info.ITR + else: return IncrementITR(inc_rpath) def patch_and_finalize(cls, dest_rpath, diffs, checkpoint = 1): """Apply diffs and finalize""" @@ -233,7 +235,7 @@ class HLDestinationStruct: DestructiveStepping.initialize(dsrp, None) if diff_rorp and not diff_rorp.isplaceholder(): RORPIter.patchonce_action(None, dsrp, diff_rorp).execute() - finalizer(dsrp) + finalizer(dsrp.index, dsrp) return dsrp try: @@ -242,7 +244,7 @@ class HLDestinationStruct: except StopIteration: break if checkpoint: SaveState.checkpoint_mirror(finalizer, dsrp) except: cls.handle_last_error(dsrp, finalizer) - finalizer.getresult() + finalizer.Finish() if Globals.preserve_hardlinks and Globals.rbdir: Hardlink.final_writedata() if checkpoint: SaveState.checkpoint_remove() @@ -258,16 +260,13 @@ class HLDestinationStruct: indexed_tuple = collated.next() Log("Processing %s" % str(indexed_tuple), 7) diff_rorp, dsrp = indexed_tuple + index = indexed_tuple.index if not dsrp: - dsrp = cls.get_dsrp(dest_rpath, indexed_tuple.index) + dsrp = cls.get_dsrp(dest_rpath, index) DestructiveStepping.initialize(dsrp, None) - indexed_tuple = IndexedTuple(indexed_tuple.index, - (diff_rorp, dsrp)) - if diff_rorp and diff_rorp.isplaceholder(): - indexed_tuple = IndexedTuple(indexed_tuple.index, - (None, dsrp)) - ITR(indexed_tuple) - finalizer(dsrp) + if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None + ITR(index, diff_rorp, dsrp) + finalizer(index, dsrp) return dsrp try: @@ -275,8 +274,8 @@ class HLDestinationStruct: try: dsrp = cls.check_skip_error(error_checked, dsrp) except StopIteration: break SaveState.checkpoint_inc_backup(ITR, finalizer, dsrp) - cls.check_skip_error(ITR.getresult, dsrp) - cls.check_skip_error(finalizer.getresult, dsrp) + cls.check_skip_error(ITR.Finish, dsrp) + cls.check_skip_error(finalizer.Finish, dsrp) except: cls.handle_last_error(dsrp, finalizer, ITR) if Globals.preserve_hardlinks: Hardlink.final_writedata() SaveState.checkpoint_remove() diff --git a/rdiff-backup/src/rpath.py b/rdiff-backup/src/rpath.py index d862951..0089bf6 100644 --- a/rdiff-backup/src/rpath.py +++ b/rdiff-backup/src/rpath.py @@ -593,13 +593,9 @@ class RPath(RORPath): self.setdata() if not self.lstat(): return # must have been deleted in meantime elif self.isdir(): - def helper(dsrp, base_init_output, branch_reduction): - if dsrp.isdir(): dsrp.rmdir() - else: dsrp.delete() - itm = IterTreeReducer(lambda x: None, lambda x,y: None, None, - helper) - for dsrp in Select(self, None).set_iter(): itm(dsrp) - itm.getresult() + itm = RpathDeleter() + for dsrp in Select(self, None).set_iter(): itm(dsrp.index, dsrp) + itm.Finish() else: self.conn.os.unlink(self.path) self.setdata() @@ -752,3 +748,15 @@ class RPathFileHook: result = self.file.close() self.closing_thunk() return result + + +class RpathDeleter(IterTreeReducer): + """Delete a directory. Called by RPath.delete()""" + def start_process(self, index, dsrp): + self.dsrp = dsrp + + def end_process(self): + if self.dsrp.isdir(): self.dsrp.rmdir() + else: self.dsrp.delete() + + |