diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-08-10 00:43:04 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-08-10 00:43:04 +0000 |
commit | 386fc7d4c764912447906324b77d83223052ac9e (patch) | |
tree | e3fa4e7fd4c4b40f28489589cb4710b5ceb7701d /rdiff-backup/rdiff_backup/librsync.py | |
parent | 9b91160b33f48de81a81088b56491574a8998d71 (diff) | |
download | rdiff-backup-386fc7d4c764912447906324b77d83223052ac9e.tar.gz |
Fixed bad high bit permissions mode in cmodule.c, and assorted changes
to make --windows-mode work.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@180 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/librsync.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/librsync.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/rdiff-backup/rdiff_backup/librsync.py b/rdiff-backup/rdiff_backup/librsync.py index 8535532..207d6a9 100644 --- a/rdiff-backup/rdiff_backup/librsync.py +++ b/rdiff-backup/rdiff_backup/librsync.py @@ -110,7 +110,6 @@ class SigFile(LikeFile): try: self.maker = _librsync.new_sigmaker() except _librsync.librsyncError, e: raise librsyncError(str(e)) - class DeltaFile(LikeFile): """File-like object which incrementally generates a librsync delta""" def __init__(self, signature, new_file): @@ -147,3 +146,41 @@ class PatchedFile(LikeFile): try: self.maker = _librsync.new_patchmaker(basis_file) except _librsync.librsyncError, e: raise librsyncError(str(e)) + +class SigGenerator: + """Calculate signature. + + Input and output is same as SigFile, but the interface is like md5 + module, not filelike object + + """ + def __init__(self): + """Return new signature instance""" + try: self.sig_maker = _librsync.new_sigmaker() + except _librsync.librsyncError, e: raise librsyncError(str(e)) + self.gotsig = None + self.buffer = "" + self.sig_string = "" + + def update(self, buf): + """Add buf to data that signature will be calculated over""" + if self.gotsig: + raise librsyncError("SigGenerator already provided signature") + self.buffer += buf + while len(self.buffer) >= blocksize: + if self.process_buffer(): + raise librsyncError("Premature EOF received from sig_maker") + + def process_buffer(self): + """Run self.buffer through sig_maker, add to self.sig_string""" + try: eof, len_buf_read, cycle_out = self.sig_maker.cycle(self.buffer) + except _librsync.librsyncError, e: raise librsyncError(str(e)) + self.buffer = self.buffer[len_buf_read:] + self.sig_string += cycle_out + return eof + + def getsig(self): + """Return signature over given data""" + while not self.process_buffer(): pass # keep running until eof + return self.sig_string + |