diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-03-21 07:34:29 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-03-21 07:34:29 +0000 |
commit | a2e3c38d72877dd9142d802e76047e10cf490e19 (patch) | |
tree | fd912dd37d0afe96adf760606d65f7b302c0678e /rdiff-backup/rdiff_backup/restore.py | |
parent | 8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf (diff) | |
download | rdiff-backup-a2e3c38d72877dd9142d802e76047e10cf490e19.tar.gz |
Added hardlink support, refactored some test cases
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@7 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/restore.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/restore.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py index 1f7d24e..9c7a42a 100644 --- a/rdiff-backup/rdiff_backup/restore.py +++ b/rdiff-backup/rdiff_backup/restore.py @@ -10,11 +10,12 @@ import tempfile class RestoreError(Exception): pass class Restore: - def RestoreFile(rest_time, rpbase, inclist, rptarget): + def RestoreFile(rest_time, rpbase, mirror_rel_index, inclist, rptarget): """Non-recursive restore function rest_time is the time in seconds to restore to, rpbase is the base name of the file being restored, + mirror_rel_index is the same as in RestoreRecursive, inclist is a list of rpaths containing all the relevant increments, and rptarget is the rpath that will be written with the restored file. @@ -25,6 +26,12 @@ class Restore: Log("Restoring %s with increments %s to %s" % (rpbase and rpbase.path, Restore.inclist2str(inclist), rptarget.path), 5) + + if (Globals.preserve_hardlinks and + Hardlink.restore_link(mirror_rel_index, rptarget)): + RPath.copy_attribs(inclist and inclist[-1] or rpbase, rptarget) + return + if not inclist or inclist[0].getinctype() == "diff": assert rpbase and rpbase.lstat(), \ "No base to go with incs %s" % Restore.inclist2str(inclist) @@ -73,14 +80,23 @@ class Restore: else: raise RestoreError("Unknown inctype %s" % inctype) RPath.copy_attribs(inc, target) - def RestoreRecursive(rest_time, mirror_base, baseinc_tup, target_base): + def RestoreRecursive(rest_time, mirror_base, mirror_rel_index, + baseinc_tup, target_base): """Recursive restore function. rest_time is the time in seconds to restore to; + mirror_base is an rpath of the mirror directory corresponding to the one to be restored; + + mirror_rel_index is the index of the mirror_base relative to + the root of the mirror directory. (The mirror_base itself + always has index (), as its index must match that of + target_base.) + baseinc_tup is the inc tuple (incdir, list of incs) to be restored; + and target_base in the dsrp of the target directory. """ @@ -99,7 +115,8 @@ class Restore: inclist = inc_tup[1] target = target_base.new_index(inc_tup.index) DestructiveStepping.initialize(target, None) - Restore.RestoreFile(rest_time, mirror, inclist, target) + Restore.RestoreFile(rest_time, mirror, mirror_rel_index, + inclist, target) target_finalizer(target) if mirror: mirror_finalizer(mirror) target_finalizer.getresult() |