renames in template manager creates xml file in wrong location

revert part of
    commit dd42f133f6
    Author: Noel Grandin <noelgrandin@gmail.com>
    Date:   Mon Jan 10 19:37:05 2022 +0200
    tdf#146375 Cannot rename user-defined categories in template manager

specifically, revert the

>    Simplify the UCB usage to just write the contents of the tempfile

and also call SvStream::Flush() in utl::TempFile::GetURL(), so that
the data actually hits the disk, so that when UCB attempts to read
the data using a separate file handle, it sees the data.

(Otherwise the temporary file data only exists in the operating system
buffers, and can only be read by the same file handle that created it)

Change-Id: I17798c53e49d65484605f2dcd96b45babd70054d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130499
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2022-02-25 12:13:00 +01:00
parent 612e7d52f8
commit 02caa6e40c
2 changed files with 15 additions and 3 deletions
+8 -3
View File
@@ -1281,12 +1281,17 @@ bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( std::u16string_view
DocTemplLocaleHelper::WriteGroupLocalizationSequence( xOutStream, aUINames, mxContext);
try {
// the SAX writer might close the stream
xOutStream->closeOutput();
// xOutStream->closeOutput();
} catch( uno::Exception& )
{}
uno::Reference < ucb::XSimpleFileAccess3 > xAccess(ucb::SimpleFileAccess::create(mxContext));
xAccess->writeFile(OUString::Concat(aUserPath) + "groupuinames.xml", xTempFile->getInputStream());
Content aTargetContent( OUString(aUserPath), maCmdEnv, comphelper::getProcessComponentContext() );
Content aSourceContent( xTempFile->getUri(), maCmdEnv, comphelper::getProcessComponentContext() );
aTargetContent.transferContent( aSourceContent,
InsertOperation::Copy,
"groupuinames.xml",
ucb::NameClash::OVERWRITE,
"text/xml" );
bResult = true;
}
+7
View File
@@ -413,6 +413,13 @@ OUString TempFile::GetFileName() const
OUString const & TempFile::GetURL() const
{
// if you request the URL, then you presumably want to access this via UCB,
// and UCB will want to open the file via a separate file handle, which means
// we have to make this file data actually hit disk. We do this here (and not
// elsewhere) to make the other (normal) paths fast. Flushing to disk
// really slows temp files down.
if (pStream)
pStream->Flush();
return aName;
}