Implement delete_all()

This commit is contained in:
Aleksander Machniak 2022-10-17 13:49:59 +02:00
parent 2a208c02ce
commit 3c44d7f768
2 changed files with 19 additions and 5 deletions

View file

@ -227,8 +227,10 @@ class kolab_storage_dav_cache extends kolab_storage_cache
/**
* Return current folder index (uid -> etag)
*/
protected function folder_index()
public function folder_index()
{
$this->_read_folder_data();
// read cache index
$sql_result = $this->db->query(
"SELECT `uid`, `etag` FROM `{$this->cache_table}` WHERE `folder_id` = ?",

View file

@ -257,7 +257,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
$uid = is_array($object) ? $object['uid'] : $object;
$success = $this->dav->delete($this->object_location($uid), $content);
$success = $this->dav->delete($this->object_location($uid));
if ($success) {
$this->cache->set($uid, false);
@ -267,7 +267,11 @@ class kolab_storage_dav_folder extends kolab_storage_folder
}
/**
* Delete all objects in a folder.
*
* Note: This method is used by kolab_addressbook plugin only
*
* @return bool True if successful, false on error
*/
public function delete_all()
{
@ -275,10 +279,18 @@ class kolab_storage_dav_folder extends kolab_storage_folder
return false;
}
// TODO: This method is used by kolab_addressbook plugin only
// $this->cache->purge();
// TODO: Maybe just deleting and re-creating a folder would be
// better, but probably might not always work (ACL)
return false;
$this->cache->synchronize();
foreach (array_keys($this->cache->folder_index()) as $uid) {
$this->dav->delete($this->object_location($uid));
}
$this->cache->purge();
return true;
}
/**