Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

Fix incorrect read/write handling in "object_store.py".

When using C stdio library, the stream must be flushed or repositioned before
switching from write operations to read operations or vv. This applies to
CPython as well since "File objects are implemented using C’s stdio package".
http://docs.python.org/library/stdtypes.html#file-objects

See also http://bugs.python.org/issue3207.

DiskObjectStore._complete_thin_pack() didn't follow these rules which made the
test

dulwich.tests.test_object_store.DiskObjectStoreTests:test_add_thin_pack

fail with

IOError: [Errno 0] Error

on Windows.

Changeset 474da97808a8

Parent ac350b129d99

by Risto Kankkunen

Changes to one file · Browse files at 474da97808a8 Showing diff from parent ac350b129d99 Diff from another changeset...

 
471
472
473
 
 
 
474
475
 
 
 
476
477
478
 
471
472
473
474
475
476
477
478
479
480
481
482
483
484
@@ -471,8 +471,14 @@
  f.seek(0)   write_pack_header(f, len(entries) + len(indexer.ext_refs()))   + # Must flush before reading (http://bugs.python.org/issue3207) + f.flush() +   # Rescan the rest of the pack, computing the SHA with the new header.   new_sha = compute_file_sha(f, end_ofs=-20) + + # Must reposition before writing (http://bugs.python.org/issue3207) + f.seek(0, os.SEEK_CUR)     # Complete the pack.   for ext_sha in indexer.ext_refs():