[Libreoffice-commits] core.git: sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jan 9 08:09:18 UTC 2018


 sfx2/source/doc/docfile.cxx |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 5259ab8104cfba60c40748ed0cd59d93df038c5b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jan 8 15:53:58 2018 +0100

    sfx2 store: create temp files next to local files
    
    This way it's more likely that we can do a cheap rename instead of a
    copy in SfxMedium::Commit().
    
    Change-Id: I45c80cd19c3ab3bc70ecbf9793dbe1bb55994ee9
    Reviewed-on: https://gerrit.libreoffice.org/47611
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 27fe78208317..3ca1d1a2d2f9 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3385,7 +3385,18 @@ void SfxMedium::CreateTempFile( bool bReplace )
         pImpl->m_aName.clear();
     }
 
-    pImpl->pTempFile = new ::utl::TempFile();
+    OUString aLogicBase;
+    if (comphelper::isFileUrl(pImpl->m_aLogicName))
+    {
+        // Try to create the temp file in the same directory.
+        sal_Int32 nOffset = pImpl->m_aLogicName.lastIndexOf("/");
+        if (nOffset != -1)
+            aLogicBase = pImpl->m_aLogicName.copy(0, nOffset);
+        if (aLogicBase == "file://")
+            // Doesn't make sense.
+            aLogicBase.clear();
+    }
+    pImpl->pTempFile = new ::utl::TempFile(aLogicBase.isEmpty() ? nullptr : &aLogicBase);
     pImpl->pTempFile->EnableKillingFile();
     pImpl->m_aName = pImpl->pTempFile->GetFileName();
     OUString aTmpURL = pImpl->pTempFile->GetURL();


More information about the Libreoffice-commits mailing list