Rev 4476: (robertc) Tweaked version of John's fix to avoid writing 0-length in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jun 24 23:57:14 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4476 [merge]
revision-id: pqm at pqm.ubuntu.com-20090624225712-x20543g8bpv6e9ny
parent: pqm at pqm.ubuntu.com-20090623231807-lxt38nkudno0040b
parent: robertc at robertcollins.net-20090623015920-vaouua88qdeqtflw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-06-24 23:57:12 +0100
message:
  (robertc) Tweaked version of John's fix to avoid writing 0-length
  	strings to local transports. (Robert Collins, John Arbash Meinel)
modified:
  bzrlib/transport/local.py      local_transport.py-20050711165921-9b1f142bfe480c24
=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/transport/local.py	2009-06-23 01:59:20 +0000
@@ -204,7 +204,8 @@
         except (IOError, OSError),e:
             self._translate_error(e, path)
         try:
-            fp.write(bytes)
+            if bytes:
+                fp.write(bytes)
             fp.commit()
         finally:
             fp.close()
@@ -285,7 +286,8 @@
     def put_bytes_non_atomic(self, relpath, bytes, mode=None,
                              create_parent_dir=False, dir_mode=None):
         def writer(fd):
-            os.write(fd, bytes)
+            if bytes:
+                os.write(fd, bytes)
         self._put_non_atomic_helper(relpath, writer, mode=mode,
                                     create_parent_dir=create_parent_dir,
                                     dir_mode=dir_mode)
@@ -370,7 +372,8 @@
         file_abspath, fd = self._get_append_file(relpath, mode=mode)
         try:
             result = self._check_mode_and_size(file_abspath, fd, mode=mode)
-            os.write(fd, bytes)
+            if bytes:
+                os.write(fd, bytes)
         finally:
             os.close(fd)
         return result




More information about the bazaar-commits mailing list