~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-24 22:57:12 UTC
  • mfrom: (4470.2.1 zero-length-writes)
  • Revision ID: pqm@pqm.ubuntu.com-20090624225712-x20543g8bpv6e9ny
(robertc) Tweaked version of John's fix to avoid writing 0-length
        strings to local transports. (Robert Collins, John Arbash Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
        except (IOError, OSError),e:
205
205
            self._translate_error(e, path)
206
206
        try:
207
 
            fp.write(bytes)
 
207
            if bytes:
 
208
                fp.write(bytes)
208
209
            fp.commit()
209
210
        finally:
210
211
            fp.close()
285
286
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
286
287
                             create_parent_dir=False, dir_mode=None):
287
288
        def writer(fd):
288
 
            os.write(fd, bytes)
 
289
            if bytes:
 
290
                os.write(fd, bytes)
289
291
        self._put_non_atomic_helper(relpath, writer, mode=mode,
290
292
                                    create_parent_dir=create_parent_dir,
291
293
                                    dir_mode=dir_mode)
370
372
        file_abspath, fd = self._get_append_file(relpath, mode=mode)
371
373
        try:
372
374
            result = self._check_mode_and_size(file_abspath, fd, mode=mode)
373
 
            os.write(fd, bytes)
 
375
            if bytes:
 
376
                os.write(fd, bytes)
374
377
        finally:
375
378
            os.close(fd)
376
379
        return result