From 48c85c6792ed001c8063fec21dfd2794c32dcd28 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 21 May 2002 23:25:47 +0000 Subject: Fixed source finalizer resume bug (although more remains to be done) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@95 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/highlevel.py | 2 +- rdiff-backup/rdiff_backup/lazy.py | 2 +- rdiff-backup/rdiff_backup/robust.py | 8 +++++--- rdiff-backup/rdiff_backup/selection.py | 20 ++++++++++++++------ rdiff-backup/src/highlevel.py | 2 +- rdiff-backup/src/lazy.py | 2 +- rdiff-backup/src/robust.py | 8 +++++--- rdiff-backup/src/selection.py | 20 ++++++++++++++------ 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/rdiff-backup/rdiff_backup/highlevel.py b/rdiff-backup/rdiff_backup/highlevel.py index e1cfc28..5ad470a 100644 --- a/rdiff-backup/rdiff_backup/highlevel.py +++ b/rdiff-backup/rdiff_backup/highlevel.py @@ -76,7 +76,7 @@ class HLSourceStruct: def iterate_from(cls): """Supply more aruments to DestructiveStepping.Iterate_from""" if cls._session_info is None: Globals.select_source.set_iter() - else: Globals.select_source.set_iter(cls._session_info.last_index) + else: Globals.select_source.set_iter(cls._session_info.last_index, 1) return Globals.select_source def split_initial_dsiter(cls): diff --git a/rdiff-backup/rdiff_backup/lazy.py b/rdiff-backup/rdiff_backup/lazy.py index 1bb2e2c..15da44d 100644 --- a/rdiff-backup/rdiff_backup/lazy.py +++ b/rdiff-backup/rdiff_backup/lazy.py @@ -241,7 +241,7 @@ class IterTreeReducer: def Finish(self): """Call at end of sequence to tie everything up""" - assert not self.finished + assert not self.finished, (self.base_index, self.index) if self.subinstance: self.subinstance.Finish() self.branch_process(self.subinstance) diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py index e92a701..b38e792 100644 --- a/rdiff-backup/rdiff_backup/robust.py +++ b/rdiff-backup/rdiff_backup/robust.py @@ -200,8 +200,7 @@ class Robust: """ try: return init_thunk() except (EnvironmentError, SkipFileException, DSRPPermError, - RPathException), exc: - Log.exception() + RPathException, RdiffException), exc: if (not isinstance(exc, EnvironmentError) or (errno.errorcode[exc[0]] in ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', @@ -209,8 +208,11 @@ class Robust: 'EIO', # reported by docv 'ETXTBSY' # reported by Campbell on some NT system ])): + Log.exception() return error_thunk(exc) - else: raise + else: + Log.exception(1, 2) + raise def listrp(rp): """Like rp.listdir() but return [] if error, and sort results""" diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index 94da6f1..70f5e7e 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -74,12 +74,15 @@ class Select: self.prefix = self.dsrpath.path self.quoting_on = Globals.quoting_enabled and quoted_filenames - def set_iter(self, starting_index = None, sel_func = None): + def set_iter(self, starting_index = None, iterate_parents = None, + sel_func = None): """Initialize more variables, get ready to iterate - Will iterate indicies greater than starting_index. Selection - function sel_func is called on each dsrp and is usually - self.Select. Returns self just for convenience. + Will iterate indicies greater than starting_index. If + iterate_parents is true, will also include parents of + starting_index in iteration. Selection function sel_func is + called on each dsrp and is usually self.Select. Returns self + just for convenience. """ if not sel_func: sel_func = self.Select @@ -88,7 +91,10 @@ class Select: self.starting_index = starting_index self.iter = self.iterate_starting_from(self.dsrpath, self.iterate_starting_from, sel_func) - else: self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func) + else: + assert not iterate_parents + self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func) + self.iterate_parents = iterate_parents self.next = self.iter.next self.__iter__ = lambda: self return self @@ -140,8 +146,10 @@ class Select: if dsrpath.index > self.starting_index: # past starting_index for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func): yield dsrp - elif dsrpath.index == self.starting_index[:len(dsrpath.index)]: + elif (dsrpath.index == self.starting_index[:len(dsrpath.index)] + and dsrpath.isdir()): # May encounter starting index on this branch + if self.iterate_parents: yield dsrpath for dsrp in self.iterate_in_dir(dsrpath, self.iterate_starting_from, sel_func): yield dsrp diff --git a/rdiff-backup/src/highlevel.py b/rdiff-backup/src/highlevel.py index e1cfc28..5ad470a 100644 --- a/rdiff-backup/src/highlevel.py +++ b/rdiff-backup/src/highlevel.py @@ -76,7 +76,7 @@ class HLSourceStruct: def iterate_from(cls): """Supply more aruments to DestructiveStepping.Iterate_from""" if cls._session_info is None: Globals.select_source.set_iter() - else: Globals.select_source.set_iter(cls._session_info.last_index) + else: Globals.select_source.set_iter(cls._session_info.last_index, 1) return Globals.select_source def split_initial_dsiter(cls): diff --git a/rdiff-backup/src/lazy.py b/rdiff-backup/src/lazy.py index 1bb2e2c..15da44d 100644 --- a/rdiff-backup/src/lazy.py +++ b/rdiff-backup/src/lazy.py @@ -241,7 +241,7 @@ class IterTreeReducer: def Finish(self): """Call at end of sequence to tie everything up""" - assert not self.finished + assert not self.finished, (self.base_index, self.index) if self.subinstance: self.subinstance.Finish() self.branch_process(self.subinstance) diff --git a/rdiff-backup/src/robust.py b/rdiff-backup/src/robust.py index e92a701..b38e792 100644 --- a/rdiff-backup/src/robust.py +++ b/rdiff-backup/src/robust.py @@ -200,8 +200,7 @@ class Robust: """ try: return init_thunk() except (EnvironmentError, SkipFileException, DSRPPermError, - RPathException), exc: - Log.exception() + RPathException, RdiffException), exc: if (not isinstance(exc, EnvironmentError) or (errno.errorcode[exc[0]] in ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', @@ -209,8 +208,11 @@ class Robust: 'EIO', # reported by docv 'ETXTBSY' # reported by Campbell on some NT system ])): + Log.exception() return error_thunk(exc) - else: raise + else: + Log.exception(1, 2) + raise def listrp(rp): """Like rp.listdir() but return [] if error, and sort results""" diff --git a/rdiff-backup/src/selection.py b/rdiff-backup/src/selection.py index 94da6f1..70f5e7e 100644 --- a/rdiff-backup/src/selection.py +++ b/rdiff-backup/src/selection.py @@ -74,12 +74,15 @@ class Select: self.prefix = self.dsrpath.path self.quoting_on = Globals.quoting_enabled and quoted_filenames - def set_iter(self, starting_index = None, sel_func = None): + def set_iter(self, starting_index = None, iterate_parents = None, + sel_func = None): """Initialize more variables, get ready to iterate - Will iterate indicies greater than starting_index. Selection - function sel_func is called on each dsrp and is usually - self.Select. Returns self just for convenience. + Will iterate indicies greater than starting_index. If + iterate_parents is true, will also include parents of + starting_index in iteration. Selection function sel_func is + called on each dsrp and is usually self.Select. Returns self + just for convenience. """ if not sel_func: sel_func = self.Select @@ -88,7 +91,10 @@ class Select: self.starting_index = starting_index self.iter = self.iterate_starting_from(self.dsrpath, self.iterate_starting_from, sel_func) - else: self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func) + else: + assert not iterate_parents + self.iter = self.Iterate(self.dsrpath, self.Iterate, sel_func) + self.iterate_parents = iterate_parents self.next = self.iter.next self.__iter__ = lambda: self return self @@ -140,8 +146,10 @@ class Select: if dsrpath.index > self.starting_index: # past starting_index for dsrp in self.Iterate(dsrpath, self.Iterate, sel_func): yield dsrp - elif dsrpath.index == self.starting_index[:len(dsrpath.index)]: + elif (dsrpath.index == self.starting_index[:len(dsrpath.index)] + and dsrpath.isdir()): # May encounter starting index on this branch + if self.iterate_parents: yield dsrpath for dsrp in self.iterate_in_dir(dsrpath, self.iterate_starting_from, sel_func): yield dsrp -- cgit v1.2.1