~l2g/duplicity/use-py.test

« back to all changes in this revision

Viewing changes to duplicity/dup_temp.py

  • Committer: Kenneth Loafman
  • Date: 2009-09-18 14:16:34 UTC
  • Revision ID: kenneth@loafman.com-20090918141634-ybi90cmfuh6svu6j
Applied "426282 [PATCH] par2 creating support", corrected some coding format issues and made sure all unit tests passed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
1
2
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
2
3
#
3
4
# Copyright 2002 Ben Escoto <ben@emerose.org>
29
30
from duplicity import tempdir
30
31
from duplicity import globals
31
32
from duplicity import gpg
 
33
from duplicity import par2_utils
32
34
 
33
35
 
34
36
def new_temppath():
169
171
        """
170
172
        We have written the last checkpoint, now encrypt or compress
171
173
        and send a copy of it to the remote for final storage.
 
174
        returns the extra bytes uploaded in par2 files
172
175
        """
173
176
        pr = file_naming.parse(self.remname)
174
177
        src = self.dirpath.append(self.partname)
175
178
        tgt = self.dirpath.append(self.remname)
 
179
 
 
180
        extra_bytes = 0
176
181
        src_iter = SrcIter(src)
177
182
        if pr.compressed:
178
183
            gpg.GzipWriteFile(src_iter, tgt.name, size = sys.maxint)
180
185
            gpg.GPGWriteFile(src_iter, tgt.name, globals.gpg_profile, size = sys.maxint)
181
186
        else:
182
187
            os.system("cp -p %s %s" % (src.name, tgt.name))
 
188
        if globals.par2:
 
189
            par = self.dirpath.append(self.remname + ".par2")
 
190
            for path, i in par2_utils.create(par.name, tgt.name):
 
191
                par_vol = self.dirpath.append(i)
 
192
                par_vol.setdata()
 
193
                extra_bytes += par_vol.getsize()
 
194
                globals.backend.put(par_vol)
 
195
        
183
196
        globals.backend.put(tgt)
 
197
 
184
198
        os.unlink(tgt.name)
 
199
        return extra_bytes
185
200
 
186
201
    def to_final(self):
187
202
        """