~mwilck/duplicity/duplicity

« back to all changes in this revision

Viewing changes to duplicity/gpg.py

  • Committer: Aaron A Whitehouse
  • Date: 2016-07-02 17:12:58 UTC
  • mfrom: (1111 duplicity-src8)
  • mto: This revision was merged to the branch mainline in revision 1113.
  • Revision ID: lists@whitehouse.kiwi.nz-20160702171258-xhnf5v5g542fcfhq
Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
357
357
        raise
358
358
 
359
359
 
360
 
def GzipWriteFile(block_iter, filename,
361
 
                  size=200 * 1024 * 1024,
362
 
                  max_footer_size=16 * 1024):
 
360
def GzipWriteFile(block_iter, filename, size=200 * 1024 * 1024, gzipped=True):
363
361
    """
364
362
    Write gzipped compressed file of given size
365
363
 
388
386
            return self.fileobj.close()
389
387
 
390
388
    file_counted = FileCounted(open(filename, "wb"))
391
 
    gzip_file = gzip.GzipFile(None, "wb", 6, file_counted)
 
389
 
 
390
    # if gzipped wrap with GzipFile else plain file out
 
391
    if gzipped:
 
392
        outfile = gzip.GzipFile(None, "wb", 6, file_counted)
 
393
    else:
 
394
        outfile = file_counted
392
395
    at_end_of_blockiter = 0
393
396
    while True:
394
397
        bytes_to_go = size - file_counted.byte_count
399
402
        except StopIteration:
400
403
            at_end_of_blockiter = 1
401
404
            break
402
 
        gzip_file.write(new_block.data)
 
405
        outfile.write(new_block.data)
403
406
 
404
 
    assert not gzip_file.close() and not file_counted.close()
 
407
    assert not outfile.close() and not file_counted.close()
405
408
    return at_end_of_blockiter
406
409
 
407
410
 
 
411
def PlainWriteFile(block_iter, filename, size=200 * 1024 * 1024, gzipped=False):
 
412
    """
 
413
    Write plain uncompressed file of given size
 
414
 
 
415
    This is like the earlier GPGWriteFile except it writes a gzipped
 
416
    file instead of a gpg'd file.  This function is somewhat out of
 
417
    place, because it doesn't deal with GPG at all, but it is very
 
418
    similar to GPGWriteFile so they might as well be defined together.
 
419
 
 
420
    The input requirements on block_iter and the output is the same as
 
421
    GPGWriteFile (returns true if wrote until end of block_iter).
 
422
    """
 
423
    return GzipWriteFile(block_iter, filename, size, gzipped)
 
424
 
 
425
 
408
426
def get_hash(hash, path, hex=1):
409
427
    """
410
428
    Return hash of path