fix folder delete

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2019-10-31 14:57:39 +01:00
parent 43fa746ad9
commit 066faaec05
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
2 changed files with 11 additions and 3 deletions

View File

@ -548,8 +548,14 @@ class Cache implements ICache {
* @throws \OC\DatabaseException
*/
private function removeChildren(ICacheEntry $entry) {
$subFolders = $this->getSubFolders($entry);
foreach ($subFolders as $folder) {
$children = $this->getFolderContentsById($entry->getId());
$childIds = array_map(function(ICacheEntry $cacheEntry) {
return $cacheEntry->getId();
}, $children);
$childFolders = array_filter($children, function ($child) {
return $child->getMimeType() == FileInfo::MIMETYPE_FOLDER;
});
foreach ($childFolders as $folder) {
$this->removeChildren($folder);
}
@ -560,7 +566,7 @@ class Cache implements ICache {
$query = $this->getQueryBuilder();
$query->delete('filecache_extended')
->whereParent($entry->getId());
->where($query->expr()->in('fileid', $query->createNamedParameter($childIds, IQueryBuilder::PARAM_INT_ARRAY)));
$query->execute();
}

View File

@ -773,6 +773,8 @@ class CacheTest extends \Test\TestCase {
$this->assertEquals(0, $entry->getCreationTime());
$this->assertEquals(25, $entry->getUploadTime());
$this->assertEquals(null, $entry->getMetadataEtag());
$this->cache->remove("sub");
}
protected function tearDown() {