summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-07-24 12:12:35 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 18:37:30 +0100
commit51579e00fef7baf5e248b1e9a2bf0e9fa8ef1a60 (patch)
tree5787a32a2729ec2da67dc8ff52f069ddc27b11b7 /ucb
parent1f783d3e5e734dbdef2ec39f1ff1370dad4f332b (diff)
ucb: webdav-curl: tdf#101094 (13) OPTIONS: Options cache removal: LOCK, UNLOCK
[ port of commit dfb714183f31d8a235797ef1ad3c517966ed4985 ] Change-Id: I1cf4689847f4f033d6f8cc40265b98b9614363e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123464 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/DAVTypes.cxx3
-rw-r--r--ucb/source/ucp/webdav-curl/DAVTypes.hxx7
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.cxx26
3 files changed, 35 insertions, 1 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
index bddbe50829b0..839b9e845846 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
@@ -26,6 +26,7 @@ DAVOptions::DAVOptions() :
m_isClass1( false ),
m_isClass2( false ),
m_isClass3( false ),
+ m_isLocked( false ),
m_aAllowedMethods(),
m_nStaleTime( 0 ),
m_sURL(),
@@ -39,6 +40,7 @@ DAVOptions::DAVOptions( const DAVOptions & rOther ) :
m_isClass1( rOther.m_isClass1 ),
m_isClass2( rOther.m_isClass2 ),
m_isClass3( rOther.m_isClass3 ),
+ m_isLocked( rOther.m_isLocked ),
m_aAllowedMethods( rOther.m_aAllowedMethods ),
m_nStaleTime( rOther.m_nStaleTime ),
m_sURL( rOther.m_sURL ),
@@ -59,6 +61,7 @@ bool DAVOptions::operator==( const DAVOptions& rOpts ) const
m_isClass1 == rOpts.m_isClass1 &&
m_isClass2 == rOpts.m_isClass2 &&
m_isClass3 == rOpts.m_isClass3 &&
+ m_isLocked == rOpts.m_isLocked &&
m_aAllowedMethods == rOpts.m_aAllowedMethods &&
m_nStaleTime == rOpts.m_nStaleTime &&
m_sURL == rOpts.m_sURL &&
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.hxx b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
index a4180c6dffc7..d5453295c733 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
@@ -71,6 +71,9 @@ namespace http_dav_ucp
bool m_isClass1;
bool m_isClass2;
bool m_isClass3;
+ // Internally used to maintain locked stated of the resource, only
+ // if it's a Class 2 resource
+ bool m_isLocked;
// contains the methods allowed on this resource
OUString m_aAllowedMethods;
@@ -112,11 +115,15 @@ namespace http_dav_ucp
bool isLockAllowed() { return ( m_aAllowedMethods.indexOf( "LOCK" ) != -1 ); };
bool isUnlockAllowed() { return ( m_aAllowedMethods.indexOf( "UNLOCK" ) != -1 ); };
+ void setLocked( bool locked = true ) { m_isLocked = locked; } ;
+ bool isLocked() { return m_isLocked; };
+
void reset() {
m_isResourceFound = false;
m_isClass1 = false;
m_isClass2 = false;
m_isClass3 = false;
+ m_isLocked = false;
m_aAllowedMethods.clear();
m_nStaleTime = 0;
m_sURL.clear();
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index ba220778c973..fdec5e34b4bc 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3041,6 +3041,8 @@ void Content::lock(
aURL = m_xIdentifier->getContentIdentifier();
}
+ OUString aTargetUrl = aURL;
+
try
{
std::unique_ptr< DAVResourceAccess > xResAccess;
@@ -3062,7 +3064,12 @@ void Content::lock(
//-1, // infinite lock
uno::Sequence< OUString >() );
+ // update the URL
+ aTargetUrl = 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 );
@@ -3071,6 +3078,7 @@ 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
@@ -3166,6 +3174,9 @@ void Content::lock(
void Content::unlock(
const uno::Reference< ucb::XCommandEnvironment >& Environment )
{
+ // save the URL to clean cache
+ OUString aTargetUrl = m_xIdentifier->getContentIdentifier();
+
try
{
std::unique_ptr< DAVResourceAccess > xResAccess;
@@ -3174,7 +3185,12 @@ void Content::unlock(
xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
}
+ // update the URL
+ aTargetUrl = xResAccess->getURL();
xResAccess->UNLOCK( Environment );
+ // remove options from cache, unlock may change it
+ // it will be refreshed when needed
+ aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -3213,6 +3229,9 @@ void Content::unlock(
}
break;
default:
+ // remove options from cache,
+ // it will be refreshed when needed
+ aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
//fallthrough
;
}
@@ -3753,7 +3772,12 @@ void Content::getResourceOptions(
rDAVOptions.isClass3() ) ?
m_nOptsCacheLifeDAV : // a WebDAV site
m_nOptsCacheLifeImplWeb; // a site implementing OPTIONS but
- // it's not DAV
+ // it's not DAV
+ // if resource is locked, will use a
+ // different lifetime
+ if( rDAVOptions.isLocked() )
+ nLifeTime = m_nOptsCacheLifeDAVLocked;
+
// check if redirected
aRedirURL = rResAccess->getURL();
if( aRedirURL == aTargetURL)