diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-08 16:49:25 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-09 09:09:27 +0100 |
commit | 2157a3536f97ff5ae7c82611a801fef7e3708983 (patch) | |
tree | 1f7e5267a0d97d55800f20f73fa3f022023abc28 /sfx2/source/doc | |
parent | 5259ab8104cfba60c40748ed0cd59d93df038c5b (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 39 |
1 files changed, 23 insertions, 16 deletions
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& ) |