summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2004-05-16 17:15:35 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2004-05-16 17:15:35 +0000
commit8c581e76fb2837f899a35d318c669c01dd13fe86 (patch)
treeb7b2d524cc0995edc5941bcc03c3531160431d0c
parent5f31870491293a3b7d1d0fbc304d9467d90ab930 (diff)
downloadrdiff-backup-8c581e76fb2837f899a35d318c669c01dd13fe86.tar.gz
Fix for backup_warn_if_infinite_regress
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r0-12@525 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/rdiff_backup/Main.py18
-rw-r--r--rdiff-backup/rdiff_backup/backup.py1
2 files changed, 11 insertions, 8 deletions
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index 15258e1..757fd71 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -324,14 +324,16 @@ option.""" % rpout.path)
def backup_warn_if_infinite_regress(rpin, rpout):
"""Warn user if destination area contained in source area"""
- if rpout.conn is rpin.conn: # it's meaningful to compare paths
- if ((len(rpout.path) > len(rpin.path)+1 and
- rpout.path[:len(rpin.path)] == rpin.path and
- rpout.path[len(rpin.path)] == '/') or
- (rpin.path == "." and rpout.path[0] != '/' and
- rpout.path[:2] != '..')):
- # Just a few heuristics, we don't have to get every case
- if Globals.backup_reader.Globals.select_source.Select(rpout): Log(
+ # Just a few heuristics, we don't have to get every case
+ if rpout.conn is not rpin.conn: return
+ if len(rpout.path) <= len(rpin.path)+1: return
+ if rpout.path[:len(rpin.path)+1] != rpin.path + '/': return
+
+ relative_rpout_comps = tuple(rpout.path[len(rpin.path)+1:].split('/'))
+ relative_rpout = rpin.new_index(relative_rpout_comps)
+ if not Globals.select_mirror.Select(relative_rpout): return
+
+ Log(
"""Warning: The destination directory '%s' may be contained in the
source directory '%s'. This could cause an infinite regress. You
may need to use the --exclude option.""" % (rpout.path, rpin.path), 2)
diff --git a/rdiff-backup/rdiff_backup/backup.py b/rdiff-backup/rdiff_backup/backup.py
index 3a57afb..b0ba31f 100644
--- a/rdiff-backup/rdiff_backup/backup.py
+++ b/rdiff-backup/rdiff_backup/backup.py
@@ -67,6 +67,7 @@ class SourceStruct:
sel.set_iter()
cache_size = Globals.pipeline_max_length * 3 # to and from+leeway
cls._source_select = rorpiter.CacheIndexable(sel, cache_size)
+ Globals.set('select_mirror', sel)
def get_source_select(cls):
"""Return source select iterator, set by set_source_select"""