[Libreoffice-commits] core.git: ucb/source

Giuseppe Castagno giuseppe.castagno at acca-esse.eu
Fri Jul 29 21:33:07 UTC 2016


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

New commits:
commit a5fc27e0575eab115de3714ae07fcac7481f4daf
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date:   Mon Jul 25 12:56:27 2016 +0200

    tdf#101094 (18) OPTIONS: Update OPTIONS cache lifetime if not found
    
    Change-Id: I1b37bba50cd41ab5eeb960927148cf6b005f3fd4
    Reviewed-on: https://gerrit.libreoffice.org/27698
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>

diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index b515ea0..01eba4e 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -2109,6 +2109,7 @@ uno::Any Content::open(
             if ( xDataSink.is() )
             {
                 // PULL: wait for client read
+                OUString aTargetURL =  m_xIdentifier->getContentIdentifier();
                 try
                 {
                     std::unique_ptr< DAVResourceAccess > xResAccess;
@@ -2148,6 +2149,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
                 }
@@ -3688,6 +3704,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 prevously 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( rURL, 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 ) ||


More information about the Libreoffice-commits mailing list