1493 self._cache = (node, curr, text) |
1494 self._cache = (node, curr, text) |
1494 self._basecache = (curr, chainbase) |
1495 self._basecache = (curr, chainbase) |
1495 return node |
1496 return node |
1496 |
1497 |
1497 def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset): |
1498 def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset): |
|
1499 # Files opened in a+ mode have inconsistent behavior on various |
|
1500 # platforms. Windows requires that a file positioning call be made |
|
1501 # when the file handle transitions between reads and writes. See |
|
1502 # 3686fa2b8eee and the mixedfilemodewrapper in windows.py. On other |
|
1503 # platforms, Python or the platform itself can be buggy. Some versions |
|
1504 # of Solaris have been observed to not append at the end of the file |
|
1505 # if the file was seeked to before the end. See issue4943 for more. |
|
1506 # |
|
1507 # We work around this issue by inserting a seek() before writing. |
|
1508 # Note: This is likely not necessary on Python 3. |
|
1509 ifh.seek(0, os.SEEK_END) |
|
1510 if dfh: |
|
1511 dfh.seek(0, os.SEEK_END) |
|
1512 |
1498 curr = len(self) - 1 |
1513 curr = len(self) - 1 |
1499 if not self._inline: |
1514 if not self._inline: |
1500 transaction.add(self.datafile, offset) |
1515 transaction.add(self.datafile, offset) |
1501 transaction.add(self.indexfile, curr * len(entry)) |
1516 transaction.add(self.indexfile, curr * len(entry)) |
1502 if data[0]: |
1517 if data[0]: |