Commit eecd0af2 authored by ben's avatar ben

Various bug fixes so it passes tests


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@93 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 4ed38185
#!/usr/bin/env python #!/usr/bin/env python
# #
# rdiff-backup -- Mirror files while keeping incremental changes # rdiff-backup -- Mirror files while keeping incremental changes
# Version 0.7.4 released May 11, 2002 # Version 0.7.5 released May 20, 2002
# Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu> # Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu>
# #
# This program is licensed under the GNU General Public License (GPL). # This program is licensed under the GNU General Public License (GPL).
......
...@@ -100,11 +100,11 @@ class HLSourceStruct: ...@@ -100,11 +100,11 @@ class HLSourceStruct:
if dest_sig: if dest_sig:
if dest_sig.isplaceholder(): yield dest_sig if dest_sig.isplaceholder(): yield dest_sig
else: else:
try: yield RORPIter.diffonce(dest_sig, dsrp) diff = Robust.check_common_error(
except (IOError, OSError, RdiffException): lambda: RORPIter.diffonce(dest_sig, dsrp),
Log.exception() lambda exc: Log("Error %s producing a diff of %s" %
Log("Error producing a diff of %s" % (str(exc), dsrp and dsrp.path), 2))
dsrp and dsrp.path) if diff: yield diff
if dsrp: finalizer(dsrp.index, dsrp) if dsrp: finalizer(dsrp.index, dsrp)
finalizer.Finish() finalizer.Finish()
return diffs() return diffs()
...@@ -269,10 +269,10 @@ class HLDestinationStruct: ...@@ -269,10 +269,10 @@ class HLDestinationStruct:
"""Run thunk, catch certain errors skip files""" """Run thunk, catch certain errors skip files"""
try: return thunk() try: return thunk()
except (EnvironmentError, SkipFileException, DSRPPermError, except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exp: RPathException), exc:
Log.exception() Log.exception()
if (not isinstance(exc, EnvironmentError) or if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in (errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY', 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv 'EIO', # reported by docv
......
import tempfile import tempfile, errno
execfile("hardlink.py") execfile("hardlink.py")
####################################################################### #######################################################################
...@@ -56,10 +56,10 @@ class RobustAction: ...@@ -56,10 +56,10 @@ class RobustAction:
try: try:
self.init_thunk() self.init_thunk()
self.final_thunk() self.final_thunk()
except Exception, exp: # Catch all errors except Exception, exc: # Catch all errors
Log.exception() Log.exception()
self.error_thunk(exp) self.error_thunk(exc)
raise exp raise exc
class Robust: class Robust:
...@@ -79,8 +79,8 @@ class Robust: ...@@ -79,8 +79,8 @@ class Robust:
ra.init_thunk() ra.init_thunk()
def final(): def final():
for ra in robust_action_list: ra.final_thunk() for ra in robust_action_list: ra.final_thunk()
def error(exp): def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exp) for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error) return RobustAction(init, final, error)
def chain_nested(robust_action_list): def chain_nested(robust_action_list):
...@@ -94,8 +94,8 @@ class Robust: ...@@ -94,8 +94,8 @@ class Robust:
ralist_copy = robust_action_list[:] ralist_copy = robust_action_list[:]
ralist_copy.reverse() ralist_copy.reverse()
for ra in ralist_copy: ra.final_thunk() for ra in ralist_copy: ra.final_thunk()
def error(exp): def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exp) for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error) return RobustAction(init, final, error)
def make_tf_robustaction(init_thunk, tempfiles, final_renames = None): def make_tf_robustaction(init_thunk, tempfiles, final_renames = None):
...@@ -118,7 +118,7 @@ class Robust: ...@@ -118,7 +118,7 @@ class Robust:
if final_name.isdir(): # Cannot rename over directory if final_name.isdir(): # Cannot rename over directory
final_name.delete() final_name.delete()
tempfiles[i].rename(final_name) tempfiles[i].rename(final_name)
def error(exp): def error(exc):
for tf in tempfiles: tf.delete() for tf in tempfiles: tf.delete()
return RobustAction(init_thunk, final, error) return RobustAction(init_thunk, final, error)
...@@ -203,7 +203,7 @@ class Robust: ...@@ -203,7 +203,7 @@ class Robust:
RPathException), exc: RPathException), exc:
Log.exception() Log.exception()
if (not isinstance(exc, EnvironmentError) or if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in (errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY', 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv 'EIO', # reported by docv
...@@ -363,7 +363,7 @@ class SaveState: ...@@ -363,7 +363,7 @@ class SaveState:
('increments',) + last_file_rorp.index) ('increments',) + last_file_rorp.index)
return Robust.symlink_action(cls._last_file_sym, symtext) return Robust.symlink_action(cls._last_file_sym, symtext)
else: return RobustAction(lambda: None, cls.touch_last_file, else: return RobustAction(lambda: None, cls.touch_last_file,
lambda exp: None) lambda exc: None)
def checkpoint_inc_backup(cls, ITR, finalizer, last_file_rorp, def checkpoint_inc_backup(cls, ITR, finalizer, last_file_rorp,
override = None): override = None):
......
...@@ -283,12 +283,12 @@ probably isn't what you meant.""" % ...@@ -283,12 +283,12 @@ probably isn't what you meant.""" %
for line in filelist_fp: for line in filelist_fp:
if not line.strip(): continue # skip blanks if not line.strip(): continue # skip blanks
try: tuple = self.filelist_parse_line(line, include) try: tuple = self.filelist_parse_line(line, include)
except FilePrefixError, exp: except FilePrefixError, exc:
prefix_warnings += 1 prefix_warnings += 1
if prefix_warnings < 6: if prefix_warnings < 6:
Log("Warning: file specification %s in filelist %s\n" Log("Warning: file specification %s in filelist %s\n"
"doesn't start with correct prefix %s, ignoring." % "doesn't start with correct prefix %s, ignoring." %
(exp, filelist_name, self.prefix), 2) (exc, filelist_name, self.prefix), 2)
if prefix_warnings == 5: if prefix_warnings == 5:
Log("Future prefix errors will not be logged.", 2) Log("Future prefix errors will not be logged.", 2)
tuple_list.append(tuple) tuple_list.append(tuple)
......
...@@ -8,7 +8,7 @@ import re, os ...@@ -8,7 +8,7 @@ import re, os
class Globals: class Globals:
# The current version of rdiff-backup # The current version of rdiff-backup
version = "0.7.4" version = "0.7.5"
# If this is set, use this value in seconds as the current time # If this is set, use this value in seconds as the current time
# instead of reading it from the clock. # instead of reading it from the clock.
......
#!/usr/bin/env python #!/usr/bin/env python
# #
# rdiff-backup -- Mirror files while keeping incremental changes # rdiff-backup -- Mirror files while keeping incremental changes
# Version 0.7.4 released May 11, 2002 # Version 0.7.5 released May 20, 2002
# Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu> # Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu>
# #
# This program is licensed under the GNU General Public License (GPL). # This program is licensed under the GNU General Public License (GPL).
......
...@@ -100,11 +100,11 @@ class HLSourceStruct: ...@@ -100,11 +100,11 @@ class HLSourceStruct:
if dest_sig: if dest_sig:
if dest_sig.isplaceholder(): yield dest_sig if dest_sig.isplaceholder(): yield dest_sig
else: else:
try: yield RORPIter.diffonce(dest_sig, dsrp) diff = Robust.check_common_error(
except (IOError, OSError, RdiffException): lambda: RORPIter.diffonce(dest_sig, dsrp),
Log.exception() lambda exc: Log("Error %s producing a diff of %s" %
Log("Error producing a diff of %s" % (str(exc), dsrp and dsrp.path), 2))
dsrp and dsrp.path) if diff: yield diff
if dsrp: finalizer(dsrp.index, dsrp) if dsrp: finalizer(dsrp.index, dsrp)
finalizer.Finish() finalizer.Finish()
return diffs() return diffs()
...@@ -269,10 +269,10 @@ class HLDestinationStruct: ...@@ -269,10 +269,10 @@ class HLDestinationStruct:
"""Run thunk, catch certain errors skip files""" """Run thunk, catch certain errors skip files"""
try: return thunk() try: return thunk()
except (EnvironmentError, SkipFileException, DSRPPermError, except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exp: RPathException), exc:
Log.exception() Log.exception()
if (not isinstance(exc, EnvironmentError) or if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in (errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY', 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv 'EIO', # reported by docv
......
...@@ -348,7 +348,7 @@ went wrong during your last backup? Using """ + mirrorrps[-1].path, 2) ...@@ -348,7 +348,7 @@ went wrong during your last backup? Using """ + mirrorrps[-1].path, 2)
""" """
self.restore_check_paths(rpin, target, 1) self.restore_check_paths(rpin, target, 1)
try: time = Time.genstrtotime(self.restore_timestr) try: time = Time.genstrtotime(self.restore_timestr)
except TimeError, exp: Log.FatalError(str(exp)) except TimeError, exc: Log.FatalError(str(exc))
self.restore_common(rpin, target, time) self.restore_common(rpin, target, time)
def restore_common(self, rpin, target, time): def restore_common(self, rpin, target, time):
...@@ -456,7 +456,7 @@ Try restoring from an increment file (the filenames look like ...@@ -456,7 +456,7 @@ Try restoring from an increment file (the filenames look like
(datadir.path,)) (datadir.path,))
try: time = Time.genstrtotime(self.remove_older_than_string) try: time = Time.genstrtotime(self.remove_older_than_string)
except TimeError, exp: Log.FatalError(str(exp)) except TimeError, exc: Log.FatalError(str(exc))
timep = Time.timetopretty(time) timep = Time.timetopretty(time)
Log("Deleting increment(s) before %s" % timep, 4) Log("Deleting increment(s) before %s" % timep, 4)
......
...@@ -107,7 +107,7 @@ class Rdiff: ...@@ -107,7 +107,7 @@ class Rdiff:
delta_tf = TempFileManager.new(rp_out, None) delta_tf = TempFileManager.new(rp_out, None)
def init(): delta_tf.write_from_fileobj(delta_fileobj) def init(): delta_tf.write_from_fileobj(delta_fileobj)
return Robust.chain_nested([RobustAction(init, delta_tf.delete, return Robust.chain_nested([RobustAction(init, delta_tf.delete,
lambda exp: delta_tf.delete), lambda exc: delta_tf.delete),
Rdiff.patch_action(rp_basis, delta_tf, Rdiff.patch_action(rp_basis, delta_tf,
rp_out, out_tf)]) rp_out, out_tf)])
...@@ -130,7 +130,7 @@ class Rdiff: ...@@ -130,7 +130,7 @@ class Rdiff:
return Robust.chain(Rdiff.write_delta_action(rpout, rpin, delta_tf), return Robust.chain(Rdiff.write_delta_action(rpout, rpin, delta_tf),
Rdiff.patch_action(rpout, delta_tf), Rdiff.patch_action(rpout, delta_tf),
RobustAction(lambda: None, delta_tf.delete, RobustAction(lambda: None, delta_tf.delete,
lambda exp: delta_tf.delete)) lambda exc: delta_tf.delete))
MakeStatic(Rdiff) MakeStatic(Rdiff)
......
import tempfile import tempfile, errno
execfile("hardlink.py") execfile("hardlink.py")
####################################################################### #######################################################################
...@@ -56,10 +56,10 @@ class RobustAction: ...@@ -56,10 +56,10 @@ class RobustAction:
try: try:
self.init_thunk() self.init_thunk()
self.final_thunk() self.final_thunk()
except Exception, exp: # Catch all errors except Exception, exc: # Catch all errors
Log.exception() Log.exception()
self.error_thunk(exp) self.error_thunk(exc)
raise exp raise exc
class Robust: class Robust:
...@@ -79,8 +79,8 @@ class Robust: ...@@ -79,8 +79,8 @@ class Robust:
ra.init_thunk() ra.init_thunk()
def final(): def final():
for ra in robust_action_list: ra.final_thunk() for ra in robust_action_list: ra.final_thunk()
def error(exp): def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exp) for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error) return RobustAction(init, final, error)
def chain_nested(robust_action_list): def chain_nested(robust_action_list):
...@@ -94,8 +94,8 @@ class Robust: ...@@ -94,8 +94,8 @@ class Robust:
ralist_copy = robust_action_list[:] ralist_copy = robust_action_list[:]
ralist_copy.reverse() ralist_copy.reverse()
for ra in ralist_copy: ra.final_thunk() for ra in ralist_copy: ra.final_thunk()
def error(exp): def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exp) for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error) return RobustAction(init, final, error)
def make_tf_robustaction(init_thunk, tempfiles, final_renames = None): def make_tf_robustaction(init_thunk, tempfiles, final_renames = None):
...@@ -118,7 +118,7 @@ class Robust: ...@@ -118,7 +118,7 @@ class Robust:
if final_name.isdir(): # Cannot rename over directory if final_name.isdir(): # Cannot rename over directory
final_name.delete() final_name.delete()
tempfiles[i].rename(final_name) tempfiles[i].rename(final_name)
def error(exp): def error(exc):
for tf in tempfiles: tf.delete() for tf in tempfiles: tf.delete()
return RobustAction(init_thunk, final, error) return RobustAction(init_thunk, final, error)
...@@ -203,7 +203,7 @@ class Robust: ...@@ -203,7 +203,7 @@ class Robust:
RPathException), exc: RPathException), exc:
Log.exception() Log.exception()
if (not isinstance(exc, EnvironmentError) or if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in (errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST', ['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY', 'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv 'EIO', # reported by docv
...@@ -363,7 +363,7 @@ class SaveState: ...@@ -363,7 +363,7 @@ class SaveState:
('increments',) + last_file_rorp.index) ('increments',) + last_file_rorp.index)
return Robust.symlink_action(cls._last_file_sym, symtext) return Robust.symlink_action(cls._last_file_sym, symtext)
else: return RobustAction(lambda: None, cls.touch_last_file, else: return RobustAction(lambda: None, cls.touch_last_file,
lambda exp: None) lambda exc: None)
def checkpoint_inc_backup(cls, ITR, finalizer, last_file_rorp, def checkpoint_inc_backup(cls, ITR, finalizer, last_file_rorp,
override = None): override = None):
......
...@@ -283,12 +283,12 @@ probably isn't what you meant.""" % ...@@ -283,12 +283,12 @@ probably isn't what you meant.""" %
for line in filelist_fp: for line in filelist_fp:
if not line.strip(): continue # skip blanks if not line.strip(): continue # skip blanks
try: tuple = self.filelist_parse_line(line, include) try: tuple = self.filelist_parse_line(line, include)
except FilePrefixError, exp: except FilePrefixError, exc:
prefix_warnings += 1 prefix_warnings += 1
if prefix_warnings < 6: if prefix_warnings < 6:
Log("Warning: file specification %s in filelist %s\n" Log("Warning: file specification %s in filelist %s\n"
"doesn't start with correct prefix %s, ignoring." % "doesn't start with correct prefix %s, ignoring." %
(exp, filelist_name, self.prefix), 2) (exc, filelist_name, self.prefix), 2)
if prefix_warnings == 5: if prefix_warnings == 5:
Log("Future prefix errors will not be logged.", 2) Log("Future prefix errors will not be logged.", 2)
tuple_list.append(tuple) tuple_list.append(tuple)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment