Comment 3 for bug 955445

Revision history for this message
Andreas Sommer (andidog) wrote :

I found out what the problem is:

(in bzrlib\vf_repository.py:2139)
new_pack._write_data('', flush=True)

(which in turn calls _write_data in bzrlib\repofmt\groupcompress_repo.py:153)
        def _write_data(bytes, flush=False, _buffer=self._buffer,
            _write=self.write_stream.write, _update=self._hash.update):
            _buffer[0].append(bytes)
            _buffer[1] += len(bytes)
            # buffer cap
            if _buffer[1] > self._cache_limit or flush:
                bytes = ''.join(_buffer[0])
                _write(bytes) # <------- THERE IT IS
                _update(bytes)
                _buffer[:] = [[], 0]

(this calls AppendBasedFileStream.write in bzrlib\transport\__init__.py:286)
    def write(self, bytes):
        self.transport.append_bytes(self.relpath, bytes)

Obviously, AppendBasedFileStream.write doesn't care if bytes is actually empty. And the flush causes a write call with an empty buffer.

So in the end, the problem boils down to how I fixed it already. But I changed the commit to check for an empty buffer in append_bytes, that will cover all possible append cases.