summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-04-15 03:33:22 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-04-17 10:57:52 +0200
commitc16c9fe5b9caa5792d930ec2f3339108d50cd2e1 (patch)
tree62e9c1a237b4577dceed7b4668fe4fe161559fe5
parentf20c1f3081c98cfb03940318e4ba7ec33f624aec (diff)
re-open output file on save to fsync to improve first-start performance
(cherry picked from commit a0b5ba2e821091b8053bfc1d2f9c99aca7431907) Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--sfx2/source/doc/docfile.cxx13
-rw-r--r--ucb/source/ucp/file/shell.cxx4
2 files changed, 12 insertions, 5 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index b9aeb16687e7..3b41fc7f9d0d 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -1942,9 +1942,20 @@ void SfxMedium::Transfer_Impl()
xComEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler,
Reference< ::com::sun::star::ucb::XProgressHandler >() );
- if ( ::utl::LocalFileHelper::IsLocalFile( aDest.GetMainURL( INetURLObject::NO_DECODE ) ) || !aDest.removeSegment() )
+ rtl::OUString aDestURL( aDest.GetMainURL( INetURLObject::NO_DECODE ) );
+ if ( ::utl::LocalFileHelper::IsLocalFile( aDestURL ) || !aDest.removeSegment() )
{
TransactedTransferForFS_Impl( aSource, aDest, xComEnv );
+
+ // Hideous - no clean way to do this, so we re-open the file just to fsync it
+ osl::File aFile( aDestURL );
+ if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None )
+ {
+ aFile.sync();
+ OSL_TRACE("fsync'd saved file '%s'\n",
+ rtl::OUStringToOString( aDestURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aFile.close();
+ }
}
else
{
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx
index 1cd150535f60..fcc238be7623 100644
--- a/ucb/source/ucp/file/shell.cxx
+++ b/ucb/source/ucp/file/shell.cxx
@@ -1913,10 +1913,6 @@ shell::write( sal_Int32 CommandId,
}
} while( nReadBytes == nRequestedBytes );
- aFile.sync(); // fsync / flush it to disk.
- OSL_TRACE( "fsync'd file '%s'\n",
- rtl::OUStringToOString( aUnqPath, RTL_TEXTENCODING_UTF8 ).getStr() );
-
err = aFile.close();
if( err != osl::FileBase::E_None )
{