Also add the root of external storages to the file id list

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-03-09 11:58:26 +01:00
parent a51e4dd259
commit 738730f7b2
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 13 additions and 5 deletions

View File

@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine\Check;
use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICache;
use OCP\Files\IHomeStorage;
use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorage;
use OCP\IL10N; use OCP\IL10N;
use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagManager;
@ -108,7 +109,7 @@ class FileSystemTags implements ICheck {
*/ */
protected function getSystemTags() { protected function getSystemTags() {
$cache = $this->storage->getCache(); $cache = $this->storage->getCache();
$fileIds = $this->getFileIds($cache, $this->path); $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class));
$systemTags = []; $systemTags = [];
foreach ($fileIds as $i => $fileId) { foreach ($fileIds as $i => $fileId) {
@ -135,17 +136,19 @@ class FileSystemTags implements ICheck {
* Get the file ids of the given path and its parents * Get the file ids of the given path and its parents
* @param ICache $cache * @param ICache $cache
* @param string $path * @param string $path
* @param bool $isExternalStorage
* @return int[] * @return int[]
*/ */
protected function getFileIds(ICache $cache, $path) { protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
$cacheId = $cache->getNumericStorageId(); $cacheId = $cache->getNumericStorageId();
if (isset($this->fileIds[$cacheId][$path])) { if (isset($this->fileIds[$cacheId][$path])) {
return $this->fileIds[$cacheId][$path]; return $this->fileIds[$cacheId][$path];
} }
if ($path !== dirname($path)) { $parentIds = [];
$parentIds = $this->getFileIds($cache, dirname($path)); if ($path !== $this->dirname($path)) {
} else { $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage);
} else if (!$isExternalStorage) {
return []; return [];
} }
@ -158,4 +161,9 @@ class FileSystemTags implements ICheck {
return $parentIds; return $parentIds;
} }
protected function dirname($path) {
$dir = dirname($path);
return $dir === '.' ? '' : $dir;
}
} }