diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-08 12:08:49 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-08 13:59:23 +0200 |
commit | 570d7f9c9f5befdb84e213916036a2b9c7321259 (patch) | |
tree | 96b64ae0dd059b0e89b6017efe3cec7947048dcd /package | |
parent | Fix typos (diff) | |
download | core-570d7f9c9f5befdb84e213916036a2b9c7321259.tar.gz core-570d7f9c9f5befdb84e213916036a2b9c7321259.zip |
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 <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
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 |