Kaydet (Commit) 2157a353 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/47612Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 5259ab81
...@@ -1721,29 +1721,36 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, ...@@ -1721,29 +1721,36 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource,
try 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() ) if (bOverWrite && ::utl::UCBContentHelper::IsDocument(aDestMainURL))
DoInternalBackup_Impl( aOriginalContent ); {
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(); Reference< XInputStream > aTempInput = aTempCont.openStream();
bTransactStarted = true;
aOriginalContent.setPropertyValue( "Size", uno::makeAny( (sal_Int64)0 ) );
aOriginalContent.writeStream( aTempInput, bOverWrite ); aOriginalContent.writeStream( aTempInput, bOverWrite );
bResult = true; 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& ) catch ( const css::ucb::CommandAbortedException& )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment