Commit 0e71ea74 authored by ben's avatar ben

Fixed '-r now' bug, and some minor typo fixes


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@121 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent e4a4b45b
......@@ -10,12 +10,6 @@ execfile("statistics.py")
class Inc:
"""Class containing increment functions"""
# This is a hack. _inc_file holds the dsrp of the latest
# increment file created, to be used in IncrementITR for
# statistics purposes. It should be given directly to the ITR
# object but there didn't seem to be a good way to pass it out.
_inc_file = None
def Increment_action(new, mirror, incpref):
"""Main file incrementing function, returns RobustAction
......@@ -116,7 +110,6 @@ class Inc:
inctime = Resume.FindTime(rp.index, inctime)
incrp = Inc.get_inc(rp, inctime, typestr)
if not incrp.lstat(): break
Inc._inc_file = incrp
return incrp
MakeStatic(Inc)
......@@ -236,6 +229,7 @@ class IncrementITR(ErrorITR, StatsITR):
else: # restore to previous state
if old_dsrp_tf.lstat(): old_dsrp_tf.rename(dsrp)
if self.incrp: self.incrp.delete()
mirror_tf.delete()
RobustAction(init_thunk, final, error).execute()
else: self.incrp = Robust.chain(
......@@ -247,7 +241,8 @@ class IncrementITR(ErrorITR, StatsITR):
def end_process(self):
"""Do final work when leaving a tree (directory)"""
diff_rorp, dsrp, incpref = self.diff_rorp, self.dsrp, self.incpref
if self.mirror_isdirectory and (diff_rorp or self.changed):
if (self.mirror_isdirectory and (diff_rorp or self.changed)
or self.directory_replacement):
if self.directory_replacement:
tf = self.directory_replacement
self.incrp = Robust.chain(
......
......@@ -28,7 +28,7 @@ class Restore:
if not isinstance(target, DSRPath): target = DSRPath(None, target)
mirror_time = Restore.get_mirror_time()
rest_time = Restore.get_rest_time(rest_time)
rest_time = Restore.get_rest_time(rest_time, mirror_time)
inc_list = Restore.get_inclist(inc_rpath)
rid = RestoreIncrementData(inc_rpath.index, inc_rpath, inc_list)
rid.sortincseq(rest_time, mirror_time)
......@@ -46,7 +46,7 @@ class Restore:
Log("Warning, two different dates for current mirror found", 2)
return Time.stringtotime(current_mirror_incs[0].getinctime())
def get_rest_time(old_rest_time):
def get_rest_time(old_rest_time, mirror_time):
"""If old_rest_time is between two increments, return older time
There is a slightly tricky reason for doing this: The rest of
......@@ -64,7 +64,8 @@ class Restore:
base_incs = Restore.get_inclist(Globals.rbdir.append("increments"))
if not base_incs: return old_rest_time
inctimes = [Time.stringtotime(inc.getinctime()) for inc in base_incs]
return max(filter(lambda time: time <= old_rest_time, inctimes))
return max(filter(lambda time: time <= old_rest_time,
inctimes + [mirror_time]))
def get_inclist(inc_rpath):
"""Returns increments with given base"""
......
......@@ -445,6 +445,7 @@ class RPath(RORPath):
"""Reproduce RPath from __getstate__ output"""
self.conn = Globals.local_connection
self.index, self.base, self.data = rpath_state
self.path = apply(os.path.join, (self.base,) + self.index)
def setdata(self):
"""Create the data dictionary"""
......
......@@ -10,12 +10,6 @@ execfile("statistics.py")
class Inc:
"""Class containing increment functions"""
# This is a hack. _inc_file holds the dsrp of the latest
# increment file created, to be used in IncrementITR for
# statistics purposes. It should be given directly to the ITR
# object but there didn't seem to be a good way to pass it out.
_inc_file = None
def Increment_action(new, mirror, incpref):
"""Main file incrementing function, returns RobustAction
......@@ -116,7 +110,6 @@ class Inc:
inctime = Resume.FindTime(rp.index, inctime)
incrp = Inc.get_inc(rp, inctime, typestr)
if not incrp.lstat(): break
Inc._inc_file = incrp
return incrp
MakeStatic(Inc)
......@@ -236,6 +229,7 @@ class IncrementITR(ErrorITR, StatsITR):
else: # restore to previous state
if old_dsrp_tf.lstat(): old_dsrp_tf.rename(dsrp)
if self.incrp: self.incrp.delete()
mirror_tf.delete()
RobustAction(init_thunk, final, error).execute()
else: self.incrp = Robust.chain(
......@@ -247,7 +241,8 @@ class IncrementITR(ErrorITR, StatsITR):
def end_process(self):
"""Do final work when leaving a tree (directory)"""
diff_rorp, dsrp, incpref = self.diff_rorp, self.dsrp, self.incpref
if self.mirror_isdirectory and (diff_rorp or self.changed):
if (self.mirror_isdirectory and (diff_rorp or self.changed)
or self.directory_replacement):
if self.directory_replacement:
tf = self.directory_replacement
self.incrp = Robust.chain(
......
......@@ -356,7 +356,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, exc: Log.FatalError(str(exc))
except TimeException, exc: Log.FatalError(str(exc))
self.restore_common(rpin, target, time)
def restore_common(self, rpin, target, time):
......@@ -383,7 +383,7 @@ Try restoring from an increment file (the filenames look like
if not rpout: rpout = RPath(Globals.local_connection,
rpin.getincbase_str())
if rpout.lstat():
Log.FatalError("Restore target %s already exists,"
Log.FatalError("Restore target %s already exists, "
"and will not be overwritten." % rpout.path)
return rpin, rpout
......
......@@ -28,7 +28,7 @@ class Restore:
if not isinstance(target, DSRPath): target = DSRPath(None, target)
mirror_time = Restore.get_mirror_time()
rest_time = Restore.get_rest_time(rest_time)
rest_time = Restore.get_rest_time(rest_time, mirror_time)
inc_list = Restore.get_inclist(inc_rpath)
rid = RestoreIncrementData(inc_rpath.index, inc_rpath, inc_list)
rid.sortincseq(rest_time, mirror_time)
......@@ -46,7 +46,7 @@ class Restore:
Log("Warning, two different dates for current mirror found", 2)
return Time.stringtotime(current_mirror_incs[0].getinctime())
def get_rest_time(old_rest_time):
def get_rest_time(old_rest_time, mirror_time):
"""If old_rest_time is between two increments, return older time
There is a slightly tricky reason for doing this: The rest of
......@@ -64,7 +64,8 @@ class Restore:
base_incs = Restore.get_inclist(Globals.rbdir.append("increments"))
if not base_incs: return old_rest_time
inctimes = [Time.stringtotime(inc.getinctime()) for inc in base_incs]
return max(filter(lambda time: time <= old_rest_time, inctimes))
return max(filter(lambda time: time <= old_rest_time,
inctimes + [mirror_time]))
def get_inclist(inc_rpath):
"""Returns increments with given base"""
......
......@@ -445,6 +445,7 @@ class RPath(RORPath):
"""Reproduce RPath from __getstate__ output"""
self.conn = Globals.local_connection
self.index, self.base, self.data = rpath_state
self.path = apply(os.path.join, (self.base,) + self.index)
def setdata(self):
"""Create the data dictionary"""
......
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