diff options
author | Giuseppe Castagno <giuseppe.castagno@acca-esse.eu> | 2015-12-04 17:10:06 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-12-15 14:24:57 +0000 |
commit | 4c82edfb3a9286a0bfef3f006e468e5c331987eb (patch) | |
tree | 9e890b822635ba6e9e93c884dd7f18578636004a /sfx2 | |
parent | 40782060f6e5c825d0086d743c1451ecaeb87a9e (diff) |
tdf#95792: fix saving file the first time on some WebDAV servers.
Some WebDAV servers don't implement section 7.3 of RFC4918:
<http://tools.ietf.org/html/rfc4918#section-7.3>
This lack of implementation breaks 'Save As...' functionality
when the target is a WebDAV server, by not locking the URL
('reserve the name for use', in RFC4918 parlance).
The server not implementing this usually answers with one of
'405 Method Not Allowed', '501 Not Implemented' or
'412 Precondition Failed' http error codes.
The fix should manage this lack of implementation.
Change-Id: Ie4689a076aafa365106d02b3ea16459a28fcde65
Reviewed-on: https://gerrit.libreoffice.org/20600
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 94633e6d5873..a9a5df0633e7 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -2083,11 +2083,37 @@ void SfxMedium::Transfer_Impl() sComment = pComments->GetValue( ); } OUString sResultURL; - if (!aTransferContent.transferContent( aSourceContent, eOperation, - aFileName, nNameClash, aMimeType, bMajor, sComment, &sResultURL, sObjectId)) + bool isTransferOK = aTransferContent.transferContent( + aSourceContent, eOperation, + aFileName, nNameClash, aMimeType, bMajor, sComment, + &sResultURL, sObjectId ); + + if ( !isTransferOK ) pImp->m_eError = ERRCODE_IO_GENERAL; else if ( !sResultURL.isEmpty( ) ) // Likely to happen only for checkin SwitchDocumentToFile( sResultURL ); + try + { + if ( GetURLObject().isAnyKnownWebDAVScheme() && + isTransferOK && + eOperation == ::ucbhelper::InsertOperation_COPY ) + { + // tdf#95272 try to re-issue a lock command when a new file is created. + // This may be needed because some WebDAV servers fail to implement the + // 'LOCK on unallocated reference', see issue comment: + // <https://bugs.documentfoundation.org/show_bug.cgi?id=95792#c8> + // and specification at: + // <http://tools.ietf.org/html/rfc4918#section-7.3> + // If the WebDAV resource is already locked by this LO instance, nothing will + // happen, e.g. the LOCK method will not be sent to the server. + ::ucbhelper::Content aLockContent = ::ucbhelper::Content( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), xComEnv, comphelper::getProcessComponentContext() ); + aLockContent.lock(); + } + } + catch ( css::uno::Exception & e ) + { + SAL_WARN( "sfx.doc", "LOCK not working while re-issuing it. Exception message: " << e.Message ); + } } catch ( const css::ucb::CommandAbortedException& ) { |