summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/robust.py
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-17 20:50:34 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-17 20:50:34 +0000
commitb7490436eb2a51749a33fe7c395bc961cfc633b4 (patch)
treee4c7b8015eeed3a681ffa946755799594f5fa827 /rdiff-backup/rdiff_backup/robust.py
parentc3beb4a2425f1ca142f1c773ca8205399b48c993 (diff)
downloadrdiff-backup-b7490436eb2a51749a33fe7c395bc961cfc633b4.tar.gz
Added some error checking code, and a wrapper for easier profiling
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@89 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/robust.py')
-rw-r--r--rdiff-backup/rdiff_backup/robust.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py
index cb09baa..da0acc4 100644
--- a/rdiff-backup/rdiff_backup/robust.py
+++ b/rdiff-backup/rdiff_backup/robust.py
@@ -191,6 +191,39 @@ class Robust:
tf.setdata()
return Robust.make_tf_robustaction(init, (tf,), (rp,))
+ def check_common_error(init_thunk, error_thunk = lambda exc: None):
+ """Execute init_thunk, if error, run error_thunk on exception
+
+ This only catches certain exceptions which seems innocent
+ enough.
+
+ """
+ try: return init_thunk()
+ except (IOError, OSError, SkipFileException, DSRPPermError,
+ RPathException), exc:
+ Log.exception()
+ if (not isinstance(exc, IOError) or
+ (isinstance(exc, IOError) and
+ (exp[0] in [2, # Means that a file is missing
+ 5, # Reported by docv (see list)
+ 13, # Permission denied IOError
+ 20, # Means a directory changed to non-dir
+ 26, # Requested by Campbell (see list) -
+ # happens on some NT systems
+ 36] # filename too long
+ ))):
+ return error_thunk(exc)
+ else: raise
+
+ def listrp(rp):
+ """Like rp.listdir() but return [] if error, and sort results"""
+ def error_thunk(exc):
+ Log("Error listing directory %s" % rp.path, 2)
+ return []
+ dir_listing = Robust.check_common_error(rp.listdir, error_thunk)
+ dir_listing.sort()
+ return dir_listing
+
MakeStatic(Robust)
@@ -554,4 +587,4 @@ class ResumeSessionInfo:
self.mirror = mirror
self.last_index = last_index
self.last_definitive = last_definitive
- self.ITR, self.finalizer, = ITR_state, finalizer_state
+ self.ITR, self.finalizer, = ITR, finalizer