ucb: webdav-curl: Related: tdf#82677, remove cached element when appropriate
[ port of commit 90ded4cbf1ffbde2ef7926fb225759896ef075bf ]
Change-Id: I7ffe75dc7a85088086f33b22eb1338ea22c1f363
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123483
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index e69633f..237c518 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -583,6 +583,8 @@ uno::Any SAL_CALL Content::execute(
xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
}
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
// clean cached value of PROPFIND property names
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->DESTROY( Environment );
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -862,6 +864,9 @@ void Content::addProperty( const css::ucb::PropertyCommandArgument &aCmdArg,
xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
}
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
// clean cached value of PROPFIND property names
// PROPPATCH can change them
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->PROPPATCH( aProppatchValues, xEnv );
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -969,6 +974,9 @@ void Content::removeProperty( const OUString& Name,
xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) );
}
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
// clean cached value of PROPFIND property names
// PROPPATCH can change them
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->PROPPATCH( aProppatchValues, xEnv );
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -1450,6 +1458,9 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
try
{
DAVResource resource;
// clean cached value of PROPFIND property names
// PROPPATCH can change them
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->HEAD( aHeaderNames, resource, xEnv );
m_bDidGetOrHead = true;
@@ -1886,6 +1897,9 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
{
try
{
// clean cached value of PROPFIND property names
// PROPPATCH can change them
removeCachedPropertyNames( xResAccess->getURL() );
// Set property values at server.
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
xResAccess->PROPPATCH( aProppatchValues, xEnv );
@@ -1947,6 +1961,9 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
targetURI.SetScheme( sourceURI.GetScheme() );
// clean cached value of PROPFIND property names
removeCachedPropertyNames( sourceURI.GetURI() );
removeCachedPropertyNames( targetURI.GetURI() );
aStaticDAVOptionsCache.removeDAVOptions( sourceURI.GetURI() );
aStaticDAVOptionsCache.removeDAVOptions( targetURI.GetURI() );
xResAccess->MOVE(
@@ -2093,6 +2110,7 @@ uno::Any Content::open(
DAVResource aResource;
std::vector< OUString > aHeaders;
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->GET( xOut, aHeaders, aResource, xEnv );
m_bDidGetOrHead = true;
@@ -2139,6 +2157,7 @@ uno::Any Content::open(
DAVResource aResource;
std::vector< OUString > aHeaders;
removeCachedPropertyNames( xResAccess->getURL() );
// check if the resource was present on the server
if( aStaticDAVOptionsCache.isResourceFound( aTargetURL ) )
{
@@ -2243,6 +2262,7 @@ void Content::post(
new DAVResourceAccess( *m_xResAccess ) );
}
removeCachedPropertyNames( xResAccess->getURL() );
uno::Reference< io::XInputStream > xResult
= xResAccess->POST( rArg.MediaType,
rArg.Referer,
@@ -2277,6 +2297,7 @@ void Content::post(
new DAVResourceAccess( *m_xResAccess ) );
}
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->POST( rArg.MediaType,
rArg.Referer,
rArg.Source,
@@ -2490,6 +2511,7 @@ void Content::insert(
if ( bCollection )
{
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->MKCOL( Environment );
}
else
@@ -2497,7 +2519,9 @@ void Content::insert(
// remove options from cache, PUT may change it
// it will be refreshed when needed
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->PUT( xInputStream, Environment );
// clean cached value of PROPFIND properties names
}
// no error , set the resourcetype to unknown type
// the resource may have transitioned from NOT FOUND or UNKNOWN to something else
@@ -2521,6 +2545,7 @@ void Content::insert(
// Destroy old resource.
try
{
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->DESTROY( Environment );
}
catch ( DAVException const & e )
@@ -2600,6 +2625,7 @@ void Content::insert(
OUString aTargetUrl = xResAccess->getURL();
try
{
removeCachedPropertyNames( xResAccess->getURL() );
// remove options from cache, PUT may change it
// it will be refreshed when needed
aStaticDAVOptionsCache.removeDAVOptions( aTargetUrl );
@@ -3128,6 +3154,7 @@ void Content::lock(
// OPTIONS may change as a consequence of the lock operation
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->LOCK( aLock, Environment );
{
@@ -3255,6 +3282,8 @@ void Content::unlock(
// remove options from cache, unlock may change it
// it will be refreshed when needed
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
// clean cached value of PROPFIND properties names
removeCachedPropertyNames( xResAccess->getURL() );
xResAccess->UNLOCK( Environment );
}
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.hxx b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
index 7c1f456..f00b826 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.hxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.hxx
@@ -296,6 +296,7 @@ public:
void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv,
DAVOptions& rDAVOptions );
static void removeCachedPropertyNames( const OUString & rURL );
};
}
diff --git a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx
index e44e088..e3ece1b 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx
@@ -259,6 +259,12 @@ bool ContentProvider::getProperty(
static PropertyNamesCache aStaticPropertyNamesCache;
// static
void Content::removeCachedPropertyNames( const OUString & rURL )
{
aStaticPropertyNamesCache.removeCachedPropertyNames( rURL );
}
// Content implementation.