ucb/source/ucp/webdav-curl/webdavcontent.cxx |   32 +++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

New commits:
commit 567f8f716bb644494fa74b9a5030c5a047c8a189
Author:     Giuseppe Castagno <[email protected]>
AuthorDate: Mon Jul 25 12:56:27 2016 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Nov 1 18:40:13 2021 +0100

    ucb: webdav-curl: tdf#101094 (18) OPTIONS: Update OPTIONS cache lifetime if 
not found
    
    [ ported from commit a5fc27e0575eab115de3714ae07fcac7481f4daf ]
    
    Change-Id: I61d06051a4526676fc4ab80d653ab7c2a9e4c209
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123470
    Tested-by: Michael Stahl <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 3f42acc56223..962d95fe945f 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -2124,6 +2124,7 @@ uno::Any Content::open(
             if ( xDataSink.is() )
             {
                 // PULL: wait for client read
+                OUString aTargetURL =  m_xIdentifier->getContentIdentifier();
                 try
                 {
                     std::unique_ptr< DAVResourceAccess > xResAccess;
@@ -2163,6 +2164,21 @@ uno::Any Content::open(
                 }
                 catch ( DAVException const & e )
                 {
+                    // check if error is SC_NOT_FOUND
+                    // if URL resource not found, set the corresponding 
resource
+                    // element in option cache and update the cache lifetime 
accordingly
+                    if( e.getStatus() == SC_NOT_FOUND )
+                    {
+                        DAVOptions aDAVOptions;
+                        if( aStaticDAVOptionsCache.getDAVOptions( aTargetURL, 
aDAVOptions ) )
+                        {
+                            // get redirected url
+                            aDAVOptions.setResourceFound( false );
+                            aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
+                                                                  
m_nOptsCacheLifeNotFound );
+                        }
+                    }
+
                     cancelCommandExecution( e, xEnv );
                     // Unreachable
                 }
@@ -3695,6 +3711,22 @@ Content::ResourceType Content::getResourceType(
                     *networkAccessAllowed = *networkAccessAllowed
                         && shouldAccessNetworkAfterException(e);
                 }
+                if ( e.getStatus() == SC_NOT_FOUND )
+                {
+                    // arrives here if OPTIONS is still cached for a resource 
previously available
+                    // operate on the OPTIONS cache:
+                    // if OPTIONS was not found, do nothing
+                    // else OPTIONS returned on a resource not existent  
(example a server that allows lock on null resource) set
+                    // not found and adjust lifetime accordingly
+                    DAVOptions aDAVOptionsInner;
+                    if 
(aStaticDAVOptionsCache.getDAVOptions(rResAccess->getURL(), aDAVOptionsInner))
+                    {
+                        // get redirected url
+                        aDAVOptionsInner.setResourceFound( false );
+                        aStaticDAVOptionsCache.addDAVOptions( aDAVOptionsInner,
+                                                              
m_nOptsCacheLifeNotFound );
+                    }
+                }
                 // if the two net events below happen, something
                 // is going on to the connection so break the command flow
                 if ( ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||

Reply via email to