From 6549259eab9e85ae0b26b6ced7f9b544ea156a0b Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 5 May 2002 03:28:57 +0000 Subject: Various changes to work with new destructive_stepping initialization code. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@69 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/destructive_stepping.py | 4 ++-- rdiff-backup/rdiff_backup/highlevel.py | 17 ++++++----------- rdiff-backup/rdiff_backup/restore.py | 3 +-- rdiff-backup/rdiff_backup/selection.py | 6 ++---- rdiff-backup/src/destructive_stepping.py | 4 ++-- rdiff-backup/src/highlevel.py | 17 ++++++----------- rdiff-backup/src/restore.py | 3 +-- rdiff-backup/src/selection.py | 6 ++---- 8 files changed, 22 insertions(+), 38 deletions(-) diff --git a/rdiff-backup/rdiff_backup/destructive_stepping.py b/rdiff-backup/rdiff_backup/destructive_stepping.py index 59effde..c5e2faa 100644 --- a/rdiff-backup/rdiff_backup/destructive_stepping.py +++ b/rdiff-backup/rdiff_backup/destructive_stepping.py @@ -6,7 +6,7 @@ execfile("rorpiter.py") # destructive-stepping - Deal with side effects from traversing trees # -class DSRPathError(Exception): +class DSRPPermError(Exception): """Exception used when a DSRPath can't get sufficient permissions""" pass @@ -85,7 +85,7 @@ class DSRPath(RPath): def warn(self, err): Log("Received error '%s' when dealing with file %s, skipping..." % (err, self.path), 1) - raise DSRPathError(self.path) + raise DSRPermError(self.path) def __getstate__(self): """Return picklable state. See RPath __getstate__.""" diff --git a/rdiff-backup/rdiff_backup/highlevel.py b/rdiff-backup/rdiff_backup/highlevel.py index 848cdbe..d0bc743 100644 --- a/rdiff-backup/rdiff_backup/highlevel.py +++ b/rdiff-backup/rdiff_backup/highlevel.py @@ -134,7 +134,7 @@ class HLDestinationStruct: cls._session_info = session_info def iterate_from(cls): - """Supply more arguments to DestructiveStepping.Iterate_from""" + """Return selection iterator to iterate all the mirror files""" if cls._session_info is None: Globals.select_mirror.set_iter() else: Globals.select_mirror.set_iter(cls._session_info.last_index) return Globals.select_mirror @@ -203,9 +203,8 @@ class HLDestinationStruct: def get_dsrp(cls, dest_rpath, index): """Return initialized dsrp based on dest_rpath with given index""" - dsrp = DSRPath(dest_rpath.conn, dest_rpath.base, index) - DestructiveStepping.initialize(dsrp, None) - return dsrp + return DSRPath(source = None, dest_rpath.conn, + dest_rpath.base, index) def get_finalizer(cls): """Return finalizer, starting from session info if necessary""" @@ -230,9 +229,7 @@ class HLDestinationStruct: indexed_tuple = collated.next() Log("Processing %s" % str(indexed_tuple), 7) diff_rorp, dsrp = indexed_tuple - if not dsrp: - dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index) - DestructiveStepping.initialize(dsrp, None) + if not dsrp: dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index) if diff_rorp and not diff_rorp.isplaceholder(): RORPIter.patchonce_action(None, dsrp, diff_rorp).execute() finalizer(dsrp.index, dsrp) @@ -261,9 +258,7 @@ class HLDestinationStruct: 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, index) - DestructiveStepping.initialize(dsrp, None) + if not dsrp: dsrp = cls.get_dsrp(dest_rpath, index) if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None ITR(index, diff_rorp, dsrp) finalizer(index, dsrp) @@ -283,7 +278,7 @@ class HLDestinationStruct: def check_skip_error(cls, thunk, dsrp): """Run thunk, catch certain errors skip files""" try: return thunk() - except (IOError, OSError, SkipFileException), exp: + except (IOError, OSError, SkipFileException, DSRPPermError), exp: Log.exception() if (not isinstance(exp, IOError) or (isinstance(exp, IOError) and diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py index 75dfec0..dcba7f3 100644 --- a/rdiff-backup/rdiff_backup/restore.py +++ b/rdiff-backup/rdiff_backup/restore.py @@ -87,8 +87,7 @@ class Restore: select_result = Globals.select_mirror.Select(target) if select_result == 0: return - if mirrorrp and (not Globals.select_source.Select(mirrorrp) or - DestructiveStepping.initialize(mirrorrp, None)): + if mirrorrp and not Globals.select_source.Select(mirrorrp): mirrorrp = None rcd = RestoreCombinedData(rid, mirrorrp, target) diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index 3ed24bc..aaa8639 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -106,9 +106,8 @@ class Select: """ s = sel_func(dsrpath) - if not s or DestructiveStepping.initialize(dsrpath, self.source): - return - if s == 1: # File is included + if s === 0: return + elif s == 1: # File is included yield dsrpath if dsrpath.isdir(): for dsrp in self.iterate_in_dir(dsrpath, rec_func, sel_func): @@ -131,7 +130,6 @@ class Select: def iterate_starting_from(self, dsrpath, rec_func, sel_func): """Like Iterate, but only yield indicies > self.starting_index""" - if DestructiveStepping.initialize(dsrpath, self.source): return if dsrpath.index > self.starting_index: # past starting_index for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func): yield dsrp diff --git a/rdiff-backup/src/destructive_stepping.py b/rdiff-backup/src/destructive_stepping.py index 59effde..c5e2faa 100644 --- a/rdiff-backup/src/destructive_stepping.py +++ b/rdiff-backup/src/destructive_stepping.py @@ -6,7 +6,7 @@ execfile("rorpiter.py") # destructive-stepping - Deal with side effects from traversing trees # -class DSRPathError(Exception): +class DSRPPermError(Exception): """Exception used when a DSRPath can't get sufficient permissions""" pass @@ -85,7 +85,7 @@ class DSRPath(RPath): def warn(self, err): Log("Received error '%s' when dealing with file %s, skipping..." % (err, self.path), 1) - raise DSRPathError(self.path) + raise DSRPermError(self.path) def __getstate__(self): """Return picklable state. See RPath __getstate__.""" diff --git a/rdiff-backup/src/highlevel.py b/rdiff-backup/src/highlevel.py index 848cdbe..d0bc743 100644 --- a/rdiff-backup/src/highlevel.py +++ b/rdiff-backup/src/highlevel.py @@ -134,7 +134,7 @@ class HLDestinationStruct: cls._session_info = session_info def iterate_from(cls): - """Supply more arguments to DestructiveStepping.Iterate_from""" + """Return selection iterator to iterate all the mirror files""" if cls._session_info is None: Globals.select_mirror.set_iter() else: Globals.select_mirror.set_iter(cls._session_info.last_index) return Globals.select_mirror @@ -203,9 +203,8 @@ class HLDestinationStruct: def get_dsrp(cls, dest_rpath, index): """Return initialized dsrp based on dest_rpath with given index""" - dsrp = DSRPath(dest_rpath.conn, dest_rpath.base, index) - DestructiveStepping.initialize(dsrp, None) - return dsrp + return DSRPath(source = None, dest_rpath.conn, + dest_rpath.base, index) def get_finalizer(cls): """Return finalizer, starting from session info if necessary""" @@ -230,9 +229,7 @@ class HLDestinationStruct: indexed_tuple = collated.next() Log("Processing %s" % str(indexed_tuple), 7) diff_rorp, dsrp = indexed_tuple - if not dsrp: - dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index) - DestructiveStepping.initialize(dsrp, None) + if not dsrp: dsrp = cls.get_dsrp(dest_rpath, diff_rorp.index) if diff_rorp and not diff_rorp.isplaceholder(): RORPIter.patchonce_action(None, dsrp, diff_rorp).execute() finalizer(dsrp.index, dsrp) @@ -261,9 +258,7 @@ class HLDestinationStruct: 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, index) - DestructiveStepping.initialize(dsrp, None) + if not dsrp: dsrp = cls.get_dsrp(dest_rpath, index) if diff_rorp and diff_rorp.isplaceholder(): diff_rorp = None ITR(index, diff_rorp, dsrp) finalizer(index, dsrp) @@ -283,7 +278,7 @@ class HLDestinationStruct: def check_skip_error(cls, thunk, dsrp): """Run thunk, catch certain errors skip files""" try: return thunk() - except (IOError, OSError, SkipFileException), exp: + except (IOError, OSError, SkipFileException, DSRPPermError), exp: Log.exception() if (not isinstance(exp, IOError) or (isinstance(exp, IOError) and diff --git a/rdiff-backup/src/restore.py b/rdiff-backup/src/restore.py index 75dfec0..dcba7f3 100644 --- a/rdiff-backup/src/restore.py +++ b/rdiff-backup/src/restore.py @@ -87,8 +87,7 @@ class Restore: select_result = Globals.select_mirror.Select(target) if select_result == 0: return - if mirrorrp and (not Globals.select_source.Select(mirrorrp) or - DestructiveStepping.initialize(mirrorrp, None)): + if mirrorrp and not Globals.select_source.Select(mirrorrp): mirrorrp = None rcd = RestoreCombinedData(rid, mirrorrp, target) diff --git a/rdiff-backup/src/selection.py b/rdiff-backup/src/selection.py index 3ed24bc..aaa8639 100644 --- a/rdiff-backup/src/selection.py +++ b/rdiff-backup/src/selection.py @@ -106,9 +106,8 @@ class Select: """ s = sel_func(dsrpath) - if not s or DestructiveStepping.initialize(dsrpath, self.source): - return - if s == 1: # File is included + if s === 0: return + elif s == 1: # File is included yield dsrpath if dsrpath.isdir(): for dsrp in self.iterate_in_dir(dsrpath, rec_func, sel_func): @@ -131,7 +130,6 @@ class Select: def iterate_starting_from(self, dsrpath, rec_func, sel_func): """Like Iterate, but only yield indicies > self.starting_index""" - if DestructiveStepping.initialize(dsrpath, self.source): return if dsrpath.index > self.starting_index: # past starting_index for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func): yield dsrp -- cgit v1.2.1