From 52247ae000a86b24cbea19a795fe0f757c68a6b1 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 24 Jul 2002 00:31:43 +0000 Subject: No longer crash on bad checkpoint data git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@171 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 6 ++++++ rdiff-backup/FAQ-body.html | 4 +--- rdiff-backup/TODO | 4 ---- rdiff-backup/rdiff_backup/robust.py | 16 +++++++++++++--- rdiff-backup/src/robust.py | 16 +++++++++++++--- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index bde900f..7ea9eaf 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -6,6 +6,12 @@ Man page now correctly included in rpm. rdiff-backup script does not have exec permissions until it is installed (thanks Jason Piterak). +Sockets are now replicated. Why not? (Suggestion by Mickey Everts) + +Bad resuming information (because, say, it is left over from a +previous version) should no longer cause exit, except when --resume is +specified. + New in v0.9.3 (2002/07/15) -------------------------- diff --git a/rdiff-backup/FAQ-body.html b/rdiff-backup/FAQ-body.html index 9d1c64f..cdc4061 100644 --- a/rdiff-backup/FAQ-body.html +++ b/rdiff-backup/FAQ-body.html @@ -40,9 +40,7 @@ static/class methods extensively, and these were only added in version defaults to an early version, you'll probably have to change the first line of the rdiff-backup script. For instance, you could set it to: -
-#/usr/bin/env python2.2
-
+
#!/usr/bin/env python2.2
diff --git a/rdiff-backup/TODO b/rdiff-backup/TODO index 1ff9588..13b2f0a 100644 --- a/rdiff-backup/TODO +++ b/rdiff-backup/TODO @@ -1,12 +1,8 @@ Write some better selection test cases to test new Iterate_fast func. -If not resuming, don't crash on badly written checkpoint_data. - Fix crash that can occur when exception is found in the middle of a file (duplicate by backing up /proc remotely). (John Goerzen) -Copy sockets (Mickey Everts) - ---------[ Long term ]--------------------------------------- diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py index 98410c9..5e2ee96 100644 --- a/rdiff-backup/rdiff_backup/robust.py +++ b/rdiff-backup/rdiff_backup/robust.py @@ -481,6 +481,10 @@ class SaveState: MakeClass(SaveState) +class ResumeException(Exception): + """Indicates some error has been encountered while trying to resume""" + pass + class Resume: """Check for old aborted backups and resume if necessary""" _session_info_list = None # List of ResumeSessionInfo's, sorted by time @@ -525,7 +529,9 @@ class Resume: times = rp_quad_dict.keys() times.sort() for time in times: - silist.append(cls.quad_to_si(time, rp_quad_dict[time])) + try: silist.append(cls.quad_to_si(time, rp_quad_dict[time])) + except ResumeException: + Log("Bad resume information found, skipping", 2) cls._session_info_list = silist def get_relevant_rps(cls): @@ -562,7 +568,8 @@ class Resume: def quad_to_si(cls, time, quad): """Take time, quadlist, return associated ResumeSessionInfo""" increment_sym, mirror_sym, checkpoint_rp, last_definitive = quad - assert not (increment_sym and mirror_sym) # both shouldn't exist + if increment_sym and mirror_sym: + raise ResumeException("both mirror and inc sym shouldn't exist") ITR, finalizer = None, None if increment_sym: mirror = None @@ -574,6 +581,7 @@ class Resume: last_index = cls.sym_to_index(mirror_sym) if checkpoint_rp: finalizer = cls.unpickle_checkpoint(checkpoint_rp) + else: raise ResumeException("Missing increment or mirror sym") return ResumeSessionInfo(mirror, time, last_index, last_definitive, finalizer, ITR) @@ -598,7 +606,9 @@ class Resume: fp = checkpoint_rp.open("rb") data = fp.read() fp.close() - return cPickle.loads(data) + try: result = cPickle.loads(data) + except cPickle.UnpicklingError: + raise ResumeException("Bad pickle at %s" % (checkpoint_rp.path,)) def ResumeCheck(cls): """Return relevant ResumeSessionInfo if there's one we should resume diff --git a/rdiff-backup/src/robust.py b/rdiff-backup/src/robust.py index 98410c9..5e2ee96 100644 --- a/rdiff-backup/src/robust.py +++ b/rdiff-backup/src/robust.py @@ -481,6 +481,10 @@ class SaveState: MakeClass(SaveState) +class ResumeException(Exception): + """Indicates some error has been encountered while trying to resume""" + pass + class Resume: """Check for old aborted backups and resume if necessary""" _session_info_list = None # List of ResumeSessionInfo's, sorted by time @@ -525,7 +529,9 @@ class Resume: times = rp_quad_dict.keys() times.sort() for time in times: - silist.append(cls.quad_to_si(time, rp_quad_dict[time])) + try: silist.append(cls.quad_to_si(time, rp_quad_dict[time])) + except ResumeException: + Log("Bad resume information found, skipping", 2) cls._session_info_list = silist def get_relevant_rps(cls): @@ -562,7 +568,8 @@ class Resume: def quad_to_si(cls, time, quad): """Take time, quadlist, return associated ResumeSessionInfo""" increment_sym, mirror_sym, checkpoint_rp, last_definitive = quad - assert not (increment_sym and mirror_sym) # both shouldn't exist + if increment_sym and mirror_sym: + raise ResumeException("both mirror and inc sym shouldn't exist") ITR, finalizer = None, None if increment_sym: mirror = None @@ -574,6 +581,7 @@ class Resume: last_index = cls.sym_to_index(mirror_sym) if checkpoint_rp: finalizer = cls.unpickle_checkpoint(checkpoint_rp) + else: raise ResumeException("Missing increment or mirror sym") return ResumeSessionInfo(mirror, time, last_index, last_definitive, finalizer, ITR) @@ -598,7 +606,9 @@ class Resume: fp = checkpoint_rp.open("rb") data = fp.read() fp.close() - return cPickle.loads(data) + try: result = cPickle.loads(data) + except cPickle.UnpicklingError: + raise ResumeException("Bad pickle at %s" % (checkpoint_rp.path,)) def ResumeCheck(cls): """Return relevant ResumeSessionInfo if there's one we should resume -- cgit v1.2.1