=== modified file 'duplicity-bin' --- duplicity-bin 2011-03-09 13:53:56 +0000 +++ duplicity-bin 2011-03-21 15:03:42 +0000 @@ -238,9 +238,15 @@ return start_index, start_block, end_index, end_block def put(tdp, dest_filename): + """ + Retrieve file size *before* calling backend.put(), which may (at least + in case of the localbackend) rename the temporary file to the target + instead of copying. + """ + putsize = tdp.getsize() backend.put(tdp, dest_filename) - putsize = tdp.getsize() - tdp.delete() + if tdp.stat: + tdp.delete() return putsize if not globals.restart: === modified file 'duplicity/backends/localbackend.py' --- duplicity/backends/localbackend.py 2010-12-04 22:14:28 +0000 +++ duplicity/backends/localbackend.py 2011-03-21 11:18:29 +0000 @@ -56,21 +56,20 @@ extra = ' '.join([op, extra]) log.FatalError(str(e), code, extra) - def put(self, source_path, remote_filename = None, rename = None): - """If rename is set, try that first, copying if doesn't work""" + def put(self, source_path, remote_filename = None): if not remote_filename: remote_filename = source_path.get_filename() target_path = self.remote_pathdir.append(remote_filename) log.Info("Writing %s" % target_path.name) - if rename: - try: - source_path.rename(target_path) - except OSError: - pass - except Exception, e: - handle_error(e, 'put', source_path.name, target_path.name) - else: - return + """Try renaming first, copying if doesn't work""" + try: + source_path.rename(target_path) + except OSError: + pass + except Exception, e: + handle_error(e, 'put', source_path.name, target_path.name) + else: + return try: target_path.writefileobj(source_path.open("rb")) except Exception, e: