package/source/zippackage/ZipPackage.cxx | 8 ++++++++ 1 file changed, 8 insertions(+)
New commits: commit 570d7f9c9f5befdb84e213916036a2b9c7321259 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Aug 8 12:08:49 2017 +0200 tdf#111481 package: seek to 0 before truncate() With this, the ZIP files created by the EPUB export don't trigger this warning on 'unzip -l': warning [test.epub]: 2546 extra bytes at beginning or within zipfile Change-Id: Ic9111d2c97b9337cf39a023def4afe4c64c4a3e5 Reviewed-on: https://gerrit.libreoffice.org/40873 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 66e40cb9d410..33ed9c1bc023 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -1395,6 +1395,14 @@ void SAL_CALL ZipPackage::commitChanges() try { xOutputStream = m_xStream->getOutputStream(); + + // Make sure we avoid a situation where the current position is + // not zero, but the underlying file is truncated in the + // meantime. + uno::Reference<io::XSeekable> xSeekable(xOutputStream, uno::UNO_QUERY); + if (xSeekable.is()) + xSeekable->seek(0); + uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY_THROW ); // after successful truncation the original file contents are already lost _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits