From a30ef01744f17349c6d9514e803b21210abb0cb7 Mon Sep 17 00:00:00 2001 From: bescoto Date: Wed, 24 Sep 2003 19:36:37 +0000 Subject: Fix for remote --list-changed-since and --list-at-time git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@447 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 3 +++ rdiff-backup/rdiff_backup/Main.py | 8 ++++++-- rdiff-backup/rdiff_backup/restore.py | 38 ++++++++++++++++++++++++------------ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index d36af8b..93aacd6 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -4,6 +4,9 @@ New in v0.13.3 (??????????) Fixed some of the --restrict options which would cause spurious violation errors. +--list-changed-since and --list-at-time now work remotely. +Thanks to Morten Werner Olsen for bug report. + New in v0.13.2 (2003/09/16) --------------------------- diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index d1c7b97..25bf913 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -662,7 +662,9 @@ def ListChangedSince(rp): restore_check_backup_dir(restore_root) mirror_rp = restore_root.new_index(restore_index) inc_rp = mirror_rp.append_path("increments", restore_index) - restore.ListChangedSince(mirror_rp, inc_rp, rest_time) + for rorp in rp.conn.restore.ListChangedSince(mirror_rp, inc_rp, rest_time): + # This is a hack, see restore.ListChangedSince for rational + print rorp.index[0] def ListAtTime(rp): @@ -673,7 +675,9 @@ def ListAtTime(rp): restore_check_backup_dir(restore_root) mirror_rp = restore_root.new_index(restore_index) inc_rp = mirror_rp.append_path("increments", restore_index) - restore.ListAtTime(mirror_rp, inc_rp, rest_time) + for rorp in rp.conn.restore.ListAtTime(mirror_rp, inc_rp, rest_time): + # Hack for remote operation, see restore.ListChangedSince for rational + print rorp.index[0] def CheckDest(dest_rp): diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py index 7e88a61..a2a5193 100644 --- a/rdiff-backup/rdiff_backup/restore.py +++ b/rdiff-backup/rdiff_backup/restore.py @@ -64,13 +64,20 @@ def get_inclist(inc_rpath): return inc_list def ListChangedSince(mirror_rp, inc_rp, restore_to_time): - """List the changed files under mirror_rp since rest time""" - MirrorS = mirror_rp.conn.restore.MirrorStruct - MirrorS.set_mirror_and_rest_times(restore_to_time) - MirrorS.initialize_rf_cache(mirror_rp, inc_rp) + """List the changed files under mirror_rp since rest time + + Notice the output is an iterator of RORPs. We do this because we + want to give the remote connection the data in buffered + increments, and this is done automatically for rorp iterators. + Encode the lines in the first element of the rorp's index. + + """ + assert mirror_rp.conn is Globals.local_connection, "Run locally only" + MirrorStruct.set_mirror_and_rest_times(restore_to_time) + MirrorStruct.initialize_rf_cache(mirror_rp, inc_rp) - cur_iter = MirrorS.get_mirror_rorp_iter(_mirror_time, 1) - old_iter = MirrorS.get_mirror_rorp_iter(_rest_time, 1) + old_iter = MirrorStruct.get_mirror_rorp_iter(_rest_time, 1) + cur_iter = MirrorStruct.get_mirror_rorp_iter(_mirror_time, 1) collated = rorpiter.Collate2Iters(old_iter, cur_iter) for old_rorp, cur_rorp in collated: if not old_rorp: change = "new" @@ -79,17 +86,22 @@ def ListChangedSince(mirror_rp, inc_rp, restore_to_time): else: change = "changed" path_desc = (old_rorp and old_rorp.get_indexpath() or cur_rorp.get_indexpath()) - print "%-7s %s" % (change, path_desc) + yield rpath.RORPath(("%-7s %s" % (change, path_desc),)) def ListAtTime(mirror_rp, inc_rp, time): - """List the files in archive at the given time""" - MirrorS = mirror_rp.conn.restore.MirrorStruct - MirrorS.set_mirror_and_rest_times(time) - MirrorS.initialize_rf_cache(mirror_rp, inc_rp) + """List the files in archive at the given time + + Output is a RORP Iterator with info in index. See ListChangedSince. + + """ + assert mirror_rp.conn is Globals.local_connection, "Run locally only" + MirrorStruct.set_mirror_and_rest_times(time) + MirrorStruct.initialize_rf_cache(mirror_rp, inc_rp) - old_iter = MirrorS.get_mirror_rorp_iter(_rest_time, 1) - for rorp in old_iter: print rorp.get_indexpath() + old_iter = MirrorStruct.get_mirror_rorp_iter(_rest_time, 1) + for rorp in old_iter: + yield rpath.RORPath((rorp.get_indexpath(),)) class MirrorStruct: -- cgit v1.2.1