Rev 3636: (robertc) Cap the amount of data we write in a single IO during local path pack operations to fix bug 255656. (Robert Collins) in http://people.ubuntu.com/~robertc/baz2.0/bug-255656

Robert Collins robertc at robertcollins.net
Fri Aug 15 05:00:01 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/bug-255656

------------------------------------------------------------
revno: 3636
revision-id: robertc at robertcollins.net-20080815035953-1pm7xp97h9hckouv
parent: pqm at pqm.ubuntu.com-20080814211426-i0rmbyhjxf4hi7pt
committer: Robert Collins <robertc at robertcollins.net>
branch nick: bug-255656
timestamp: Fri 2008-08-15 13:59:53 +1000
message:
  (robertc) Cap the amount of data we write in a single IO during local path pack operations to fix bug 255656. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
=== modified file 'NEWS'
--- a/NEWS	2008-08-14 20:42:22 +0000
+++ b/NEWS	2008-08-15 03:59:53 +0000
@@ -20,6 +20,9 @@
 
   BUG FIXES:
 
+    * Pack operations on windows network shares will work even with large
+      files. (Robert Collins, #255656)
+
     * ``WorkingTree4`` trees will now correctly report missing-and-new
       paths in the output of ``iter_changes``. (Robert Collins)
 

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2008-06-24 22:53:43 +0000
+++ b/bzrlib/transport/__init__.py	2008-08-15 03:59:53 +0000
@@ -254,7 +254,14 @@
         self.file_handle.close()
 
     def write(self, bytes):
-        self.file_handle.write(bytes)
+        # Write data in 5MB chunks rather than all at once, because very large
+        # writes fail on some platforms (e.g. Windows with SMB  mounted
+        # drives).
+        segment_size = 5242880 # 5MB
+        segments = range(len(bytes) / segment_size + 1)
+        for segment_index in segments:
+            segment = buffer(bytes, segment_index * segment_size, segment_size)
+            self.file_handle.write(segment)
 
 
 class AppendBasedFileStream(FileStream):




More information about the bazaar-commits mailing list