~krissn/duplicity/xattr-selection-support

« back to all changes in this revision

Viewing changes to duplicity/diffdir.py

  • Committer: Kenneth Loafman
  • Date: 2011-10-05 14:13:31 UTC
  • mfrom: (777.1.9 duplicity.tarfile)
  • Revision ID: kenneth@loafman.com-20111005141331-1butbl95nwt5czon
MergedĀ inĀ lp:~mterry/duplicity/tarfile

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
import cStringIO, types
31
31
from duplicity import statistics
 
32
from duplicity import util
32
33
from duplicity.path import * #@UnusedWildImport
33
34
from duplicity.lazy import * #@UnusedWildImport
34
35
 
181
182
    """
182
183
    collated = collate2iters(new_iter, sig_iter)
183
184
    if sig_fileobj:
184
 
        sigTarFile = tarfile.TarFile("arbitrary", "w", sig_fileobj)
 
185
        sigTarFile = util.make_tarfile("w", sig_fileobj)
185
186
    else:
186
187
        sigTarFile = None
187
188
    for new_path, sig_path in collated:
224
225
    """
225
226
    Convert signature tar file object open for reading into path iter
226
227
    """
227
 
    tf = tarfile.TarFile("Arbitrary Name", "r", sigtarobj)
228
 
    tf.debug = 2
 
228
    tf = util.make_tarfile("r", sigtarobj)
 
229
    tf.debug = 1
229
230
    for tarinfo in tf:
 
231
        tiname = util.get_tarinfo_name(tarinfo)
230
232
        for prefix in ["signature/", "snapshot/", "deleted/"]:
231
 
            if tarinfo.name.startswith(prefix):
232
 
                # strip prefix and from name and set it to difftype
233
 
                name, difftype = tarinfo.name[len(prefix):], prefix[:-1]
 
233
            if tiname.startswith(prefix):
 
234
                # strip prefix and '/' from name and set it to difftype
 
235
                name, difftype = tiname[len(prefix):], prefix[:-1]
234
236
                break
235
237
        else:
236
 
            raise DiffDirException("Bad tarinfo name %s" % (tarinfo.name,))
 
238
            raise DiffDirException("Bad tarinfo name %s" % (tiname,))
237
239
 
238
240
        index = tuple(name.split("/"))
239
241
        if not index[-1]:
464
466
        self.remember_value = None          # holds index of next block
465
467
        self.remember_block = None          # holds block of next block
466
468
 
467
 
        # We need to instantiate a dummy TarFile just to get access to
468
 
        # some of the functions like _get_full_headers.
469
 
        self.tf = tarfile.TarFromIterator(None)
470
 
 
471
469
    def tarinfo2tarblock(self, index, tarinfo, file_data = ""):
472
470
        """
473
471
        Make tarblock out of tarinfo and file data
474
472
        """
475
473
        tarinfo.size = len(file_data)
476
 
        headers = self.tf._get_full_headers(tarinfo)
 
474
        headers = tarinfo.tobuf()
477
475
        blocks, remainder = divmod(tarinfo.size, tarfile.BLOCKSIZE) #@UnusedVariable
478
476
        if remainder > 0:
479
477
            filler_data = "\0" * (tarfile.BLOCKSIZE - remainder)