summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-01-09 20:37:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-11 07:19:25 +0100
commit5c00fadcc94bdfaefb9bee81a9bc610838fb9615 (patch)
tree4db4427d07a14aa3e09b65fe98226b4ec3b6efc9 /package
parentdd42f133f604ee2f7e0ffbca6a8d94fb8f95dfe5 (diff)
optimise and simplify ZipOutputEntryInThread
by just using the tempfile service as intended, we can stay on the "happy path" which means that, on Windows, if there is sufficient system RAM, the temporary file never even hits the disk. Change-Id: I3b27cf09bd40a4cfee01c23273af05860708a16f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128258 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipOutputEntry.hxx2
-rw-r--r--package/source/zipapi/ZipOutputEntry.cxx21
2 files changed, 8 insertions, 15 deletions
diff --git a/package/inc/ZipOutputEntry.hxx b/package/inc/ZipOutputEntry.hxx
index 9ef4466ed742..078c07359de5 100644
--- a/package/inc/ZipOutputEntry.hxx
+++ b/package/inc/ZipOutputEntry.hxx
@@ -110,7 +110,7 @@ protected:
class ZipOutputEntryInThread final : public ZipOutputEntry
{
class Task;
- OUString m_aTempURL;
+ css::uno::Reference<css::io::XTempFile> m_xTempFile;
std::exception_ptr m_aParallelDeflateException;
std::atomic<bool> m_bFinished;
diff --git a/package/source/zipapi/ZipOutputEntry.cxx b/package/source/zipapi/ZipOutputEntry.cxx
index a30eba7c981c..734840865a14 100644
--- a/package/source/zipapi/ZipOutputEntry.cxx
+++ b/package/source/zipapi/ZipOutputEntry.cxx
@@ -250,17 +250,12 @@ ZipOutputEntryInThread::ZipOutputEntryInThread(
void ZipOutputEntryInThread::createBufferFile()
{
- assert(!m_xOutStream.is() && m_aTempURL.isEmpty() &&
+ assert(!m_xOutStream && !m_xTempFile &&
"should only be called in the threaded mode where there is no existing stream yet");
- uno::Reference < io::XTempFile > xTempFile(
+ m_xTempFile.set(
io::TempFile::create(m_xContext),
uno::UNO_SET_THROW );
- xTempFile->setRemoveFile(false);
- m_aTempURL = xTempFile->getUri();
- assert(!m_aTempURL.isEmpty());
-
- uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess(ucb::SimpleFileAccess::create(m_xContext));
- m_xOutStream = xTempAccess->openFileWrite(m_aTempURL);
+ m_xOutStream = m_xTempFile->getOutputStream();
}
void ZipOutputEntryInThread::closeBufferFile()
@@ -271,15 +266,13 @@ void ZipOutputEntryInThread::closeBufferFile()
void ZipOutputEntryInThread::deleteBufferFile()
{
- assert(!m_xOutStream.is() && !m_aTempURL.isEmpty());
- uno::Reference < ucb::XSimpleFileAccess3 > xAccess(ucb::SimpleFileAccess::create(m_xContext));
- xAccess->kill(m_aTempURL);
+ assert(!m_xOutStream.is() && m_xTempFile);
+ m_xTempFile.clear();
}
uno::Reference< io::XInputStream > ZipOutputEntryInThread::getData() const
{
- uno::Reference < ucb::XSimpleFileAccess3 > xTempAccess(ucb::SimpleFileAccess::create(m_xContext));
- return xTempAccess->openFileRead(m_aTempURL);
+ return m_xTempFile->getInputStream();
}
class ZipOutputEntryInThread::Task : public comphelper::ThreadTask
@@ -313,7 +306,7 @@ private:
{
if (mpEntry->m_xOutStream.is())
mpEntry->closeBufferFile();
- if (!mpEntry->m_aTempURL.isEmpty())
+ if (mpEntry->m_xTempFile)
mpEntry->deleteBufferFile();
}
catch (uno::Exception const&)