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
#
# 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>
#
# This program is licensed under the GNU General Public License (GPL).
......
......@@ -100,11 +100,11 @@ class HLSourceStruct:
if dest_sig:
if dest_sig.isplaceholder(): yield dest_sig
else:
try: yield RORPIter.diffonce(dest_sig, dsrp)
except (IOError, OSError, RdiffException):
Log.exception()
Log("Error producing a diff of %s" %
dsrp and dsrp.path)
diff = Robust.check_common_error(
lambda: RORPIter.diffonce(dest_sig, dsrp),
lambda exc: Log("Error %s producing a diff of %s" %
(str(exc), dsrp and dsrp.path), 2))
if diff: yield diff
if dsrp: finalizer(dsrp.index, dsrp)
finalizer.Finish()
return diffs()
......@@ -269,10 +269,10 @@ class HLDestinationStruct:
"""Run thunk, catch certain errors skip files"""
try: return thunk()
except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exp:
RPathException), exc:
Log.exception()
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv
......
import tempfile
import tempfile, errno
execfile("hardlink.py")
#######################################################################
......@@ -56,10 +56,10 @@ class RobustAction:
try:
self.init_thunk()
self.final_thunk()
except Exception, exp: # Catch all errors
except Exception, exc: # Catch all errors
Log.exception()
self.error_thunk(exp)
raise exp
self.error_thunk(exc)
raise exc
class Robust:
......@@ -79,8 +79,8 @@ class Robust:
ra.init_thunk()
def final():
for ra in robust_action_list: ra.final_thunk()
def error(exp):
for ra in ras_with_completed_inits: ra.error_thunk(exp)
def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error)
def chain_nested(robust_action_list):
......@@ -94,8 +94,8 @@ class Robust:
ralist_copy = robust_action_list[:]
ralist_copy.reverse()
for ra in ralist_copy: ra.final_thunk()
def error(exp):
for ra in ras_with_completed_inits: ra.error_thunk(exp)
def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error)
def make_tf_robustaction(init_thunk, tempfiles, final_renames = None):
......@@ -118,7 +118,7 @@ class Robust:
if final_name.isdir(): # Cannot rename over directory
final_name.delete()
tempfiles[i].rename(final_name)
def error(exp):
def error(exc):
for tf in tempfiles: tf.delete()
return RobustAction(init_thunk, final, error)
......@@ -203,7 +203,7 @@ class Robust:
RPathException), exc:
Log.exception()
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv
......@@ -363,7 +363,7 @@ class SaveState:
('increments',) + last_file_rorp.index)
return Robust.symlink_action(cls._last_file_sym, symtext)
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,
override = None):
......
......@@ -283,12 +283,12 @@ probably isn't what you meant.""" %
for line in filelist_fp:
if not line.strip(): continue # skip blanks
try: tuple = self.filelist_parse_line(line, include)
except FilePrefixError, exp:
except FilePrefixError, exc:
prefix_warnings += 1
if prefix_warnings < 6:
Log("Warning: file specification %s in filelist %s\n"
"doesn't start with correct prefix %s, ignoring." %
(exp, filelist_name, self.prefix), 2)
(exc, filelist_name, self.prefix), 2)
if prefix_warnings == 5:
Log("Future prefix errors will not be logged.", 2)
tuple_list.append(tuple)
......
......@@ -8,7 +8,7 @@ import re, os
class Globals:
# 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
# instead of reading it from the clock.
......
#!/usr/bin/env python
#
# 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>
#
# This program is licensed under the GNU General Public License (GPL).
......
......@@ -100,11 +100,11 @@ class HLSourceStruct:
if dest_sig:
if dest_sig.isplaceholder(): yield dest_sig
else:
try: yield RORPIter.diffonce(dest_sig, dsrp)
except (IOError, OSError, RdiffException):
Log.exception()
Log("Error producing a diff of %s" %
dsrp and dsrp.path)
diff = Robust.check_common_error(
lambda: RORPIter.diffonce(dest_sig, dsrp),
lambda exc: Log("Error %s producing a diff of %s" %
(str(exc), dsrp and dsrp.path), 2))
if diff: yield diff
if dsrp: finalizer(dsrp.index, dsrp)
finalizer.Finish()
return diffs()
......@@ -269,10 +269,10 @@ class HLDestinationStruct:
"""Run thunk, catch certain errors skip files"""
try: return thunk()
except (EnvironmentError, SkipFileException, DSRPPermError,
RPathException), exp:
RPathException), exc:
Log.exception()
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv
......
......@@ -348,7 +348,7 @@ went wrong during your last backup? Using """ + mirrorrps[-1].path, 2)
"""
self.restore_check_paths(rpin, target, 1)
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)
def restore_common(self, rpin, target, time):
......@@ -456,7 +456,7 @@ Try restoring from an increment file (the filenames look like
(datadir.path,))
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)
Log("Deleting increment(s) before %s" % timep, 4)
......
......@@ -107,7 +107,7 @@ class Rdiff:
delta_tf = TempFileManager.new(rp_out, None)
def init(): delta_tf.write_from_fileobj(delta_fileobj)
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,
rp_out, out_tf)])
......@@ -130,7 +130,7 @@ class Rdiff:
return Robust.chain(Rdiff.write_delta_action(rpout, rpin, delta_tf),
Rdiff.patch_action(rpout, delta_tf),
RobustAction(lambda: None, delta_tf.delete,
lambda exp: delta_tf.delete))
lambda exc: delta_tf.delete))
MakeStatic(Rdiff)
......
import tempfile
import tempfile, errno
execfile("hardlink.py")
#######################################################################
......@@ -56,10 +56,10 @@ class RobustAction:
try:
self.init_thunk()
self.final_thunk()
except Exception, exp: # Catch all errors
except Exception, exc: # Catch all errors
Log.exception()
self.error_thunk(exp)
raise exp
self.error_thunk(exc)
raise exc
class Robust:
......@@ -79,8 +79,8 @@ class Robust:
ra.init_thunk()
def final():
for ra in robust_action_list: ra.final_thunk()
def error(exp):
for ra in ras_with_completed_inits: ra.error_thunk(exp)
def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error)
def chain_nested(robust_action_list):
......@@ -94,8 +94,8 @@ class Robust:
ralist_copy = robust_action_list[:]
ralist_copy.reverse()
for ra in ralist_copy: ra.final_thunk()
def error(exp):
for ra in ras_with_completed_inits: ra.error_thunk(exp)
def error(exc):
for ra in ras_with_completed_inits: ra.error_thunk(exc)
return RobustAction(init, final, error)
def make_tf_robustaction(init_thunk, tempfiles, final_renames = None):
......@@ -118,7 +118,7 @@ class Robust:
if final_name.isdir(): # Cannot rename over directory
final_name.delete()
tempfiles[i].rename(final_name)
def error(exp):
def error(exc):
for tf in tempfiles: tf.delete()
return RobustAction(init_thunk, final, error)
......@@ -203,7 +203,7 @@ class Robust:
RPathException), exc:
Log.exception()
if (not isinstance(exc, EnvironmentError) or
(errno.errorcode[exp[0]] in
(errno.errorcode[exc[0]] in
['EPERM', 'ENOENT', 'EACCES', 'EBUSY', 'EEXIST',
'ENOTDIR', 'ENAMETOOLONG', 'EINTR', 'ENOTEMPTY',
'EIO', # reported by docv
......@@ -363,7 +363,7 @@ class SaveState:
('increments',) + last_file_rorp.index)
return Robust.symlink_action(cls._last_file_sym, symtext)
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,
override = None):
......
......@@ -283,12 +283,12 @@ probably isn't what you meant.""" %
for line in filelist_fp:
if not line.strip(): continue # skip blanks
try: tuple = self.filelist_parse_line(line, include)
except FilePrefixError, exp:
except FilePrefixError, exc:
prefix_warnings += 1
if prefix_warnings < 6:
Log("Warning: file specification %s in filelist %s\n"
"doesn't start with correct prefix %s, ignoring." %
(exp, filelist_name, self.prefix), 2)
(exc, filelist_name, self.prefix), 2)
if prefix_warnings == 5:
Log("Future prefix errors will not be logged.", 2)
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