summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-11-24 00:21:50 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-11-24 00:21:50 +0000
commit33ebc912eaf524abbb30952ab8a601502ed53674 (patch)
tree02d99e6318bca4d13c2614531a2b0f6f8f038456 /rdiff-backup/rdiff_backup
parent8c16d0e2c767afb0d67fdf05a687197e4370f82f (diff)
downloadrdiff-backup-33ebc912eaf524abbb30952ab8a601502ed53674.tar.gz
Added restore selection file fix
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r0-12@500 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r--rdiff-backup/rdiff_backup/Main.py22
-rw-r--r--rdiff-backup/rdiff_backup/restore.py16
-rw-r--r--rdiff-backup/rdiff_backup/selection.py7
3 files changed, 25 insertions, 20 deletions
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index 5eae9bf..ad0440c 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -20,7 +20,7 @@
"""Start (and end) here - read arguments, set global settings, etc."""
from __future__ import generators
-import getopt, sys, re, os
+import getopt, sys, re, os, cStringIO
from log import Log, LoggerError, ErrorLog
import Globals, Time, SetConnections, selection, robust, rpath, \
manage, backup, connection, restore, FilenameMapping, \
@@ -408,16 +408,26 @@ def restore_common(rpin, target, time):
Log("Restore ended", 4)
def restore_set_select(mirror_rp, target):
- """Set the selection iterator on mirror side from command line args
+ """Set the selection iterator on both side from command line args
- Here we set the selector on the mirror side, because that is where
- we will be filtering, but the pathnames are relative to the target
- directory.
+ We must set both sides because restore filtering is different from
+ select filtering. For instance, if a file is excluded it should
+ not be deleted from the target directory.
+
+ The StringIO stuff is because filelists need to be read and then
+ duplicated, because we need two copies of them now.
"""
+ def fp2string(fp):
+ buf = fp.read()
+ assert not fp.close()
+ return buf
+ select_data = map(fp2string, select_files)
if select_opts:
mirror_rp.conn.restore.MirrorStruct.set_mirror_select(
- target, select_opts, *select_files)
+ target, select_opts, *map(cStringIO.StringIO, select_data))
+ target.conn.restore.TargetStruct.set_target_select(
+ target, select_opts, *map(cStringIO.StringIO, select_data))
def restore_start_log(rpin, target, time):
"""Open restore log file, log initial message"""
diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py
index 0e2e5c0..3ec3a77 100644
--- a/rdiff-backup/rdiff_backup/restore.py
+++ b/rdiff-backup/rdiff_backup/restore.py
@@ -25,11 +25,6 @@ import Globals, Time, Rdiff, Hardlink, rorpiter, selection, rpath, \
log, static, robust, metadata, statistics, TempFile
-# This should be set to selection.Select objects over the source and
-# mirror directories respectively.
-_select_source = None
-_select_mirror = None
-
# This will be set to the time of the current mirror
_mirror_time = None
# This will be set to the exact time to restore to (not restore_to_time)
@@ -251,9 +246,16 @@ static.MakeClass(MirrorStruct)
class TargetStruct:
"""Hold functions to be run on the target side when restoring"""
- def get_initial_iter(cls, target):
+ _select = None
+ def set_target_select(cls, target, select_opts, *filelists):
"""Return a selection object iterating the rorpaths in target"""
- return selection.Select(target).set_iter()
+ cls._select = selection.Select(target)
+ cls._select.ParseArgs(select_opts, filelists)
+ cls._select.set_iter()
+
+ def get_initial_iter(cls, target):
+ """Return selector previously set with set_initial_iter"""
+ return cls._select or selection.Select(target).set_iter()
def patch(cls, target, diff_iter):
"""Patch target with the diffs from the mirror side
diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py
index b63db4a..30bc68f 100644
--- a/rdiff-backup/rdiff_backup/selection.py
+++ b/rdiff-backup/rdiff_backup/selection.py
@@ -694,10 +694,3 @@ class FilterIterITRB(rorpiter.ITRBranch):
assert s == 2, s
self.base_queue = next_rorp
-
-
-
-
-
-
-