1
|
Index: rpath.py
|
2
|
===================================================================
|
3
|
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/rpath.py,v
|
4
|
retrieving revision 1.142
|
5
|
diff -u -r1.142 rpath.py
|
6
|
--- rpath.py 23 Jun 2009 23:56:30 -0000 1.142
|
7
|
+++ rpath.py 3 Jan 2011 03:27:04 -0000
|
8
|
@@ -58,10 +58,44 @@
|
9
|
def copyfileobj(inputfp, outputfp):
|
10
|
"""Copies file inputfp to outputfp in blocksize intervals"""
|
11
|
blocksize = Globals.blocksize
|
12
|
+
|
13
|
+ sparse = False
|
14
|
+ buf = None
|
15
|
while 1:
|
16
|
inbuf = inputfp.read(blocksize)
|
17
|
if not inbuf: break
|
18
|
- outputfp.write(inbuf)
|
19
|
+
|
20
|
+ if not buf:
|
21
|
+ buf = inbuf
|
22
|
+ else:
|
23
|
+ buf += inbuf
|
24
|
+
|
25
|
+ # Combine "short" reads
|
26
|
+ if (len(buf) < blocksize):
|
27
|
+ continue
|
28
|
+
|
29
|
+ buflen = len(buf)
|
30
|
+ if buf == "\x00" * buflen:
|
31
|
+ outputfp.seek(buflen, os.SEEK_CUR)
|
32
|
+ buf = None
|
33
|
+ # flag sparse=True, that we seek()ed, but have not written yet
|
34
|
+ # The filesize is wrong until we write
|
35
|
+ sparse = True
|
36
|
+ else:
|
37
|
+ outputfp.write(buf)
|
38
|
+ buf = None
|
39
|
+
|
40
|
+ # We wrote, so clear sparse.
|
41
|
+ sparse = False
|
42
|
+
|
43
|
+
|
44
|
+ if buf:
|
45
|
+ outputfp.write(buf)
|
46
|
+ buf = None
|
47
|
+
|
48
|
+ elif sparse:
|
49
|
+ outputfp.seek(-1, os.SEEK_CUR)
|
50
|
+ outputfp.write("\x00")
|
51
|
|
52
|
def cmpfileobj(fp1, fp2):
|
53
|
"""True if file objects fp1 and fp2 contain same data"""
|