sfx2/source/doc/docfile.cxx | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 5441ed518d36ac12a6bd0c517e2cfc24aff94d50
Author: Justin Luth <[email protected]>
AuthorDate: Thu Mar 14 11:29:08 2024 -0400
Commit: Miklos Vajna <[email protected]>
CommitDate: Mon Mar 18 14:20:38 2024 +0100
tdf#40244 tdf#160192: create tempFile elsewhere if LogicBase is RO
This avoids a crash/infinite loop in specific read-only folder
situation (where the lock file already exists).
It also fixes ODF files giving three misleading/unclear
notices when attempting to save into a read-only folder.
When LO saves a file, it saves to a temporary file
and then moves that file overtop of the previous one, IIUC.
Prior to 6.1 5259ab8104cfba60c40748ed0cd59d93df038c5b
that temporary file was stored in the /tmp directory (IIUC),
but was changed to be in the same folder for easier renaming,
same filesystem etc.
Note that typically this situation would fail
since a locking file also could not be created.
However in the case where the lock file already exists,
then all the pieces are in place to actually modify the document.
By falling back to the /tmp folder if the document's folder
is read-only, we can still modify a writeable document.
Change-Id: Ie027fc05934f2c071f7a91007255801c179bff49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164841
Tested-by: Jenkins
Reviewed-by: Justin Luth <[email protected]>
Reviewed-by: Miklos Vajna <[email protected]>
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index c90fb794f690..b58d27c95fa4 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -4038,6 +4038,8 @@ void SfxMedium::CreateTempFile( bool bReplace )
OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
+ if (!aLogicBase.isEmpty() && pImpl->pTempFile->GetFileName().isEmpty())
+ pImpl->pTempFile.reset(new ::utl::TempFileNamed());
pImpl->pTempFile->EnableKillingFile();
pImpl->m_aName = pImpl->pTempFile->GetFileName();
OUString aTmpURL = pImpl->pTempFile->GetURL();
@@ -4134,6 +4136,8 @@ void SfxMedium::CreateTempFileNoCopy()
OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
+ if (!aLogicBase.isEmpty() && pImpl->pTempFile->GetFileName().isEmpty())
+ pImpl->pTempFile.reset(new ::utl::TempFileNamed());
pImpl->pTempFile->EnableKillingFile();
pImpl->m_aName = pImpl->pTempFile->GetFileName();
if ( pImpl->m_aName.isEmpty() )