From 2157a3536f97ff5ae7c82611a801fef7e3708983 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 8 Jan 2018 16:49:25 +0100 Subject: sfx2 store: try rename before copying Rename is cheaper then copying the content over manually, so try that first. Change-Id: Ieb1d03e39501c1565dae7e3290e318a09ee18965 Reviewed-on: https://gerrit.libreoffice.org/47612 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sfx2/source/doc/docfile.cxx | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'sfx2/source/doc') diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 3ca1d1a2d2f9..2e4ac54ba75c 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1721,29 +1721,36 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, try { - if( bOverWrite && ::utl::UCBContentHelper::IsDocument( aDest.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) ) + OUString aSourceMainURL = aSource.GetMainURL(INetURLObject::DecodeMechanism::NONE); + OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); + if (comphelper::isFileUrl(aDestMainURL) && osl::File::move(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) + bResult = true; + else { - if( pImpl->m_aBackupURL.isEmpty() ) - DoInternalBackup_Impl( aOriginalContent ); + if (bOverWrite && ::utl::UCBContentHelper::IsDocument(aDestMainURL)) + { + if( pImpl->m_aBackupURL.isEmpty() ) + DoInternalBackup_Impl( aOriginalContent ); - if( !pImpl->m_aBackupURL.isEmpty() ) + if( !pImpl->m_aBackupURL.isEmpty() ) + { + Reference< XInputStream > aTempInput = aTempCont.openStream(); + bTransactStarted = true; + aOriginalContent.setPropertyValue( "Size", uno::makeAny( (sal_Int64)0 ) ); + aOriginalContent.writeStream( aTempInput, bOverWrite ); + bResult = true; + } + else + { + pImpl->m_eError = ERRCODE_SFX_CANTCREATEBACKUP; + } + } + else { Reference< XInputStream > aTempInput = aTempCont.openStream(); - bTransactStarted = true; - aOriginalContent.setPropertyValue( "Size", uno::makeAny( (sal_Int64)0 ) ); aOriginalContent.writeStream( aTempInput, bOverWrite ); bResult = true; } - else - { - pImpl->m_eError = ERRCODE_SFX_CANTCREATEBACKUP; - } - } - else - { - Reference< XInputStream > aTempInput = aTempCont.openStream(); - aOriginalContent.writeStream( aTempInput, bOverWrite ); - bResult = true; } } catch ( const css::ucb::CommandAbortedException& ) -- cgit