ucb/source/ucp/webdav-curl/webdavcontent.cxx |   21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

New commits:
commit ccbb358db241b8b2564f3d5ac2991ffff5d3deeb
Author:     Giuseppe Castagno <giuseppe.casta...@acca-esse.eu>
AuthorDate: Wed Aug 10 14:05:08 2016 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:41:51 2021 +0100

    ucb: webdav-curl: tdf#101094 (21): Simplify cache removal: LOCK, UNLOCK
    
    [ port of commit 508f78298833f45fd9e2e789aa26cca125719baf ]
    
    Change-Id: I81185c11ed3ad216b13fcbafee45ea3a48cf0a12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123474
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 46442074d8b2..212c8732b91e 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3116,8 +3116,6 @@ void Content::lock(
         aURL = m_xIdentifier->getContentIdentifier();
     }
 
-    OUString    aTargetUrl = aURL;
-
     try
     {
         std::unique_ptr< DAVResourceAccess > xResAccess;
@@ -3139,12 +3137,9 @@ void Content::lock(
             //-1, // infinite lock
             uno::Sequence< OUString >() );
 
-        //  update the URL
-        aTargetUrl = xResAccess->getURL();
-
+        // OPTIONS may change as a consequence of the lock operation
+        aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
         xResAccess->LOCK( aLock, Environment );
-        // OPTIONS may have changed as a consequence of the lock operation
-        aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
 
         {
             osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -3153,7 +3148,6 @@ void Content::lock(
     }
     catch ( DAVException const & e )
     {
-        aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
         // check if the exception thrown is 'already locked'
         // this exception is mapped directly to the ucb correct one, without
         // going into the cancelCommandExecution() user interaction
@@ -3253,8 +3247,6 @@ void Content::lock(
 void Content::unlock(
         const uno::Reference< ucb::XCommandEnvironment >& Environment )
 {
-    // save the URL to clean cache
-    OUString    aTargetUrl = m_xIdentifier->getContentIdentifier();
 
     try
     {
@@ -3264,8 +3256,6 @@ void Content::unlock(
             xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
         }
 
-        // update the URL
-        aTargetUrl = xResAccess->getURL();
         // check if the target URL is a Class1 DAV
         DAVOptions aDAVOptions;
         getResourceOptions( Environment, aDAVOptions, xResAccess );
@@ -3273,10 +3263,10 @@ void Content::unlock(
         // at least class one is needed
         if( aDAVOptions.isClass1() )
         {
-            xResAccess->UNLOCK( Environment );
             // remove options from cache, unlock may change it
             // it will be refreshed when needed
-            aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
+            aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
+            xResAccess->UNLOCK( Environment );
         }
 
         {
@@ -3316,9 +3306,6 @@ void Content::unlock(
                 }
                 break;
             default:
-                // remove options from cache,
-                // it will be refreshed when needed
-                aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
                 //fallthrough
                 ;
         }

Reply via email to