summaryrefslogtreecommitdiff
path: root/rdiff-backup/misc/librsync-many-files.py
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup/misc/librsync-many-files.py')
-rw-r--r--rdiff-backup/misc/librsync-many-files.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/rdiff-backup/misc/librsync-many-files.py b/rdiff-backup/misc/librsync-many-files.py
new file mode 100644
index 0000000..239d2fb
--- /dev/null
+++ b/rdiff-backup/misc/librsync-many-files.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+"""Use librsync to transform everything in one dir to another"""
+
+import sys, os, librsync
+
+dir1, dir2 = sys.argv[1:3]
+for i in xrange(1000):
+ dir1fn = "%s/%s" % (dir1, i)
+ dir2fn = "%s/%s" % (dir2, i)
+
+ # Write signature file
+ f1 = open(dir1fn, "rb")
+ sigfile = open("sig", "wb")
+ librsync.filesig(f1, sigfile, 2048)
+ f1.close()
+ sigfile.close()
+
+ # Write delta file
+ f2 = open(dir2fn, "r")
+ sigfile = open("sig", "rb")
+ deltafile = open("delta", "wb")
+ librsync.filerdelta(sigfile, f2, deltafile)
+ f2.close()
+ sigfile.close()
+ deltafile.close()
+
+ # Write patched file
+ f1 = open(dir1fn, "rb")
+ newfile = open("%s/%s.out" % (dir1, i), "wb")
+ deltafile = open("delta", "rb")
+ librsync.filepatch(f1, deltafile, newfile)
+ f1.close()
+ deltafile.close()
+ newfile.close()
+
+