1
0

Scanner.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Ari Selseng <ari@selseng.net>
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Björn Schießle <bjoern@schiessle.org>
  8. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  9. * @author Daniel Jagszent <daniel@jagszent.de>
  10. * @author Joas Schilling <coding@schilljs.com>
  11. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  12. * @author Lukas Reschke <lukas@statuscode.ch>
  13. * @author Martin Mattel <martin.mattel@diemattels.at>
  14. * @author Morris Jobke <hey@morrisjobke.de>
  15. * @author Owen Winkler <a_github@midnightcircus.com>
  16. * @author Robin Appelman <robin@icewind.nl>
  17. * @author Robin McCorkell <robin@mccorkell.me.uk>
  18. * @author Thomas Müller <thomas.mueller@tmit.eu>
  19. * @author Vincent Petry <vincent@nextcloud.com>
  20. *
  21. * @license AGPL-3.0
  22. *
  23. * This code is free software: you can redistribute it and/or modify
  24. * it under the terms of the GNU Affero General Public License, version 3,
  25. * as published by the Free Software Foundation.
  26. *
  27. * This program is distributed in the hope that it will be useful,
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. * GNU Affero General Public License for more details.
  31. *
  32. * You should have received a copy of the GNU Affero General Public License, version 3,
  33. * along with this program. If not, see <http://www.gnu.org/licenses/>
  34. *
  35. */
  36. namespace OC\Files\Cache;
  37. use Doctrine\DBAL\Exception;
  38. use OC\Files\Storage\Wrapper\Encryption;
  39. use OCP\Files\Cache\IScanner;
  40. use OCP\Files\ForbiddenException;
  41. use OCP\Files\Storage\IReliableEtagStorage;
  42. use OCP\Lock\ILockingProvider;
  43. use OC\Files\Storage\Wrapper\Encoding;
  44. use OC\Files\Storage\Wrapper\Jail;
  45. use OC\Hooks\BasicEmitter;
  46. use Psr\Log\LoggerInterface;
  47. /**
  48. * Class Scanner
  49. *
  50. * Hooks available in scope \OC\Files\Cache\Scanner:
  51. * - scanFile(string $path, string $storageId)
  52. * - scanFolder(string $path, string $storageId)
  53. * - postScanFile(string $path, string $storageId)
  54. * - postScanFolder(string $path, string $storageId)
  55. *
  56. * @package OC\Files\Cache
  57. */
  58. class Scanner extends BasicEmitter implements IScanner {
  59. /**
  60. * @var \OC\Files\Storage\Storage $storage
  61. */
  62. protected $storage;
  63. /**
  64. * @var string $storageId
  65. */
  66. protected $storageId;
  67. /**
  68. * @var \OC\Files\Cache\Cache $cache
  69. */
  70. protected $cache;
  71. /**
  72. * @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache
  73. */
  74. protected $cacheActive;
  75. /**
  76. * @var bool $useTransactions whether to use transactions
  77. */
  78. protected $useTransactions = true;
  79. /**
  80. * @var \OCP\Lock\ILockingProvider
  81. */
  82. protected $lockingProvider;
  83. public function __construct(\OC\Files\Storage\Storage $storage) {
  84. $this->storage = $storage;
  85. $this->storageId = $this->storage->getId();
  86. $this->cache = $storage->getCache();
  87. $this->cacheActive = !\OC::$server->getConfig()->getSystemValue('filesystem_cache_readonly', false);
  88. $this->lockingProvider = \OC::$server->getLockingProvider();
  89. }
  90. /**
  91. * Whether to wrap the scanning of a folder in a database transaction
  92. * On default transactions are used
  93. *
  94. * @param bool $useTransactions
  95. */
  96. public function setUseTransactions($useTransactions) {
  97. $this->useTransactions = $useTransactions;
  98. }
  99. /**
  100. * get all the metadata of a file or folder
  101. * *
  102. *
  103. * @param string $path
  104. * @return array|null an array of metadata of the file
  105. */
  106. protected function getData($path) {
  107. $data = $this->storage->getMetaData($path);
  108. if (is_null($data)) {
  109. \OC::$server->get(LoggerInterface::class)->debug("!!! Path '$path' is not accessible or present !!!", ['app' => 'core']);
  110. }
  111. return $data;
  112. }
  113. /**
  114. * scan a single file and store it in the cache
  115. *
  116. * @param string $file
  117. * @param int $reuseExisting
  118. * @param int $parentId
  119. * @param array|null|false $cacheData existing data in the cache for the file to be scanned
  120. * @param bool $lock set to false to disable getting an additional read lock during scanning
  121. * @param null $data the metadata for the file, as returned by the storage
  122. * @return array|null an array of metadata of the scanned file
  123. * @throws \OCP\Lock\LockedException
  124. */
  125. public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
  126. if ($file !== '') {
  127. try {
  128. $this->storage->verifyPath(dirname($file), basename($file));
  129. } catch (\Exception $e) {
  130. return null;
  131. }
  132. }
  133. // only proceed if $file is not a partial file, blacklist is handled by the storage
  134. if (!self::isPartialFile($file)) {
  135. // acquire a lock
  136. if ($lock) {
  137. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  138. $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  139. }
  140. }
  141. try {
  142. $data = $data ?? $this->getData($file);
  143. } catch (ForbiddenException $e) {
  144. if ($lock) {
  145. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  146. $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  147. }
  148. }
  149. return null;
  150. }
  151. try {
  152. if ($data) {
  153. // pre-emit only if it was a file. By that we avoid counting/treating folders as files
  154. if ($data['mimetype'] !== 'httpd/unix-directory') {
  155. $this->emit('\OC\Files\Cache\Scanner', 'scanFile', [$file, $this->storageId]);
  156. \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', ['path' => $file, 'storage' => $this->storageId]);
  157. }
  158. $parent = dirname($file);
  159. if ($parent === '.' || $parent === '/') {
  160. $parent = '';
  161. }
  162. if ($parentId === -1) {
  163. $parentId = $this->cache->getParentId($file);
  164. }
  165. // scan the parent if it's not in the cache (id -1) and the current file is not the root folder
  166. if ($file && $parentId === -1) {
  167. $parentData = $this->scanFile($parent);
  168. if (!$parentData) {
  169. return null;
  170. }
  171. $parentId = $parentData['fileid'];
  172. }
  173. if ($parent) {
  174. $data['parent'] = $parentId;
  175. }
  176. if (is_null($cacheData)) {
  177. /** @var CacheEntry $cacheData */
  178. $cacheData = $this->cache->get($file);
  179. }
  180. if ($cacheData && $reuseExisting && isset($cacheData['fileid'])) {
  181. // prevent empty etag
  182. $etag = empty($cacheData['etag']) ? $data['etag'] : $cacheData['etag'];
  183. $fileId = $cacheData['fileid'];
  184. $data['fileid'] = $fileId;
  185. // only reuse data if the file hasn't explicitly changed
  186. if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) {
  187. $data['mtime'] = $cacheData['mtime'];
  188. if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
  189. $data['size'] = $cacheData['size'];
  190. }
  191. if ($reuseExisting & self::REUSE_ETAG && !$this->storage->instanceOfStorage(IReliableEtagStorage::class)) {
  192. $data['etag'] = $etag;
  193. }
  194. }
  195. // we only updated unencrypted_size if it's already set
  196. if ($cacheData['unencrypted_size'] === 0) {
  197. unset($data['unencrypted_size']);
  198. }
  199. // Only update metadata that has changed
  200. $newData = array_diff_assoc($data, $cacheData->getData());
  201. } else {
  202. // we only updated unencrypted_size if it's already set
  203. unset($data['unencrypted_size']);
  204. $newData = $data;
  205. $fileId = -1;
  206. }
  207. if (!empty($newData)) {
  208. // Reset the checksum if the data has changed
  209. $newData['checksum'] = '';
  210. $newData['parent'] = $parentId;
  211. $data['fileid'] = $this->addToCache($file, $newData, $fileId);
  212. }
  213. $data['oldSize'] = ($cacheData && isset($cacheData['size'])) ? $cacheData['size'] : 0;
  214. if ($cacheData && isset($cacheData['encrypted'])) {
  215. $data['encrypted'] = $cacheData['encrypted'];
  216. }
  217. // post-emit only if it was a file. By that we avoid counting/treating folders as files
  218. if ($data['mimetype'] !== 'httpd/unix-directory') {
  219. $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', [$file, $this->storageId]);
  220. \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', ['path' => $file, 'storage' => $this->storageId]);
  221. }
  222. } else {
  223. $this->removeFromCache($file);
  224. }
  225. } catch (\Exception $e) {
  226. if ($lock) {
  227. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  228. $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  229. }
  230. }
  231. throw $e;
  232. }
  233. // release the acquired lock
  234. if ($lock) {
  235. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  236. $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  237. }
  238. }
  239. if ($data && !isset($data['encrypted'])) {
  240. $data['encrypted'] = false;
  241. }
  242. return $data;
  243. }
  244. return null;
  245. }
  246. protected function removeFromCache($path) {
  247. \OC_Hook::emit('Scanner', 'removeFromCache', ['file' => $path]);
  248. $this->emit('\OC\Files\Cache\Scanner', 'removeFromCache', [$path]);
  249. if ($this->cacheActive) {
  250. $this->cache->remove($path);
  251. }
  252. }
  253. /**
  254. * @param string $path
  255. * @param array $data
  256. * @param int $fileId
  257. * @return int the id of the added file
  258. */
  259. protected function addToCache($path, $data, $fileId = -1) {
  260. if (isset($data['scan_permissions'])) {
  261. $data['permissions'] = $data['scan_permissions'];
  262. }
  263. \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]);
  264. $this->emit('\OC\Files\Cache\Scanner', 'addToCache', [$path, $this->storageId, $data]);
  265. if ($this->cacheActive) {
  266. if ($fileId !== -1) {
  267. $this->cache->update($fileId, $data);
  268. return $fileId;
  269. } else {
  270. return $this->cache->insert($path, $data);
  271. }
  272. } else {
  273. return -1;
  274. }
  275. }
  276. /**
  277. * @param string $path
  278. * @param array $data
  279. * @param int $fileId
  280. */
  281. protected function updateCache($path, $data, $fileId = -1) {
  282. \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]);
  283. $this->emit('\OC\Files\Cache\Scanner', 'updateCache', [$path, $this->storageId, $data]);
  284. if ($this->cacheActive) {
  285. if ($fileId !== -1) {
  286. $this->cache->update($fileId, $data);
  287. } else {
  288. $this->cache->put($path, $data);
  289. }
  290. }
  291. }
  292. /**
  293. * scan a folder and all it's children
  294. *
  295. * @param string $path
  296. * @param bool $recursive
  297. * @param int $reuse
  298. * @param bool $lock set to false to disable getting an additional read lock during scanning
  299. * @return array|null an array of the meta data of the scanned file or folder
  300. */
  301. public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
  302. if ($reuse === -1) {
  303. $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
  304. }
  305. if ($lock) {
  306. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  307. $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider);
  308. $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  309. }
  310. }
  311. try {
  312. $data = $this->scanFile($path, $reuse, -1, null, $lock);
  313. if ($data && $data['mimetype'] === 'httpd/unix-directory') {
  314. $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock, $data);
  315. $data['size'] = $size;
  316. }
  317. } finally {
  318. if ($lock) {
  319. if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
  320. $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
  321. $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider);
  322. }
  323. }
  324. }
  325. return $data;
  326. }
  327. /**
  328. * Get the children currently in the cache
  329. *
  330. * @param int $folderId
  331. * @return array[]
  332. */
  333. protected function getExistingChildren($folderId) {
  334. $existingChildren = [];
  335. $children = $this->cache->getFolderContentsById($folderId);
  336. foreach ($children as $child) {
  337. $existingChildren[$child['name']] = $child;
  338. }
  339. return $existingChildren;
  340. }
  341. /**
  342. * scan all the files and folders in a folder
  343. *
  344. * @param string $path
  345. * @param bool $recursive
  346. * @param int $reuse
  347. * @param int $folderId id for the folder to be scanned
  348. * @param bool $lock set to false to disable getting an additional read lock during scanning
  349. * @param array $data the data of the folder before (re)scanning the children
  350. * @return int|float the size of the scanned folder or -1 if the size is unknown at this stage
  351. */
  352. protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true, array $data = []) {
  353. if ($reuse === -1) {
  354. $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
  355. }
  356. $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', [$path, $this->storageId]);
  357. $size = 0;
  358. if (!is_null($folderId)) {
  359. $folderId = $this->cache->getId($path);
  360. }
  361. $childQueue = $this->handleChildren($path, $recursive, $reuse, $folderId, $lock, $size);
  362. foreach ($childQueue as $child => $childId) {
  363. $childSize = $this->scanChildren($child, $recursive, $reuse, $childId, $lock);
  364. if ($childSize === -1) {
  365. $size = -1;
  366. } elseif ($size !== -1) {
  367. $size += $childSize;
  368. }
  369. }
  370. $oldSize = $data['size'] ?? null;
  371. // for encrypted storages, we trigger a regular folder size calculation instead of using the calculated size
  372. // to make sure we also updated the unencrypted-size where applicable
  373. if ($this->storage->instanceOfStorage(Encryption::class)) {
  374. $this->cache->calculateFolderSize($path);
  375. } else {
  376. if ($this->cacheActive && $oldSize !== $size) {
  377. $this->cache->update($folderId, ['size' => $size]);
  378. }
  379. }
  380. $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', [$path, $this->storageId]);
  381. return $size;
  382. }
  383. private function handleChildren($path, $recursive, $reuse, $folderId, $lock, &$size) {
  384. // we put this in it's own function so it cleans up the memory before we start recursing
  385. $existingChildren = $this->getExistingChildren($folderId);
  386. $newChildren = iterator_to_array($this->storage->getDirectoryContent($path));
  387. if (count($existingChildren) === 0 && count($newChildren) === 0) {
  388. // no need to do a transaction
  389. return [];
  390. }
  391. if ($this->useTransactions) {
  392. \OC::$server->getDatabaseConnection()->beginTransaction();
  393. }
  394. $exceptionOccurred = false;
  395. $childQueue = [];
  396. $newChildNames = [];
  397. foreach ($newChildren as $fileMeta) {
  398. $permissions = isset($fileMeta['scan_permissions']) ? $fileMeta['scan_permissions'] : $fileMeta['permissions'];
  399. if ($permissions === 0) {
  400. continue;
  401. }
  402. $originalFile = $fileMeta['name'];
  403. $file = trim(\OC\Files\Filesystem::normalizePath($originalFile), '/');
  404. if (trim($originalFile, '/') !== $file) {
  405. // encoding mismatch, might require compatibility wrapper
  406. \OC::$server->get(LoggerInterface::class)->debug('Scanner: Skipping non-normalized file name "'. $originalFile . '" in path "' . $path . '".', ['app' => 'core']);
  407. $this->emit('\OC\Files\Cache\Scanner', 'normalizedNameMismatch', [$path ? $path . '/' . $originalFile : $originalFile]);
  408. // skip this entry
  409. continue;
  410. }
  411. $newChildNames[] = $file;
  412. $child = $path ? $path . '/' . $file : $file;
  413. try {
  414. $existingData = isset($existingChildren[$file]) ? $existingChildren[$file] : false;
  415. $data = $this->scanFile($child, $reuse, $folderId, $existingData, $lock, $fileMeta);
  416. if ($data) {
  417. if ($data['mimetype'] === 'httpd/unix-directory' && $recursive === self::SCAN_RECURSIVE) {
  418. $childQueue[$child] = $data['fileid'];
  419. } elseif ($data['mimetype'] === 'httpd/unix-directory' && $recursive === self::SCAN_RECURSIVE_INCOMPLETE && $data['size'] === -1) {
  420. // only recurse into folders which aren't fully scanned
  421. $childQueue[$child] = $data['fileid'];
  422. } elseif ($data['size'] === -1) {
  423. $size = -1;
  424. } elseif ($size !== -1) {
  425. $size += $data['size'];
  426. }
  427. }
  428. } catch (Exception $ex) {
  429. // might happen if inserting duplicate while a scanning
  430. // process is running in parallel
  431. // log and ignore
  432. if ($this->useTransactions) {
  433. \OC::$server->getDatabaseConnection()->rollback();
  434. \OC::$server->getDatabaseConnection()->beginTransaction();
  435. }
  436. \OC::$server->get(LoggerInterface::class)->debug('Exception while scanning file "' . $child . '"', [
  437. 'app' => 'core',
  438. 'exception' => $ex,
  439. ]);
  440. $exceptionOccurred = true;
  441. } catch (\OCP\Lock\LockedException $e) {
  442. if ($this->useTransactions) {
  443. \OC::$server->getDatabaseConnection()->rollback();
  444. }
  445. throw $e;
  446. }
  447. }
  448. $removedChildren = \array_diff(array_keys($existingChildren), $newChildNames);
  449. foreach ($removedChildren as $childName) {
  450. $child = $path ? $path . '/' . $childName : $childName;
  451. $this->removeFromCache($child);
  452. }
  453. if ($this->useTransactions) {
  454. \OC::$server->getDatabaseConnection()->commit();
  455. }
  456. if ($exceptionOccurred) {
  457. // It might happen that the parallel scan process has already
  458. // inserted mimetypes but those weren't available yet inside the transaction
  459. // To make sure to have the updated mime types in such cases,
  460. // we reload them here
  461. \OC::$server->getMimeTypeLoader()->reset();
  462. }
  463. return $childQueue;
  464. }
  465. /**
  466. * check if the file should be ignored when scanning
  467. * NOTE: files with a '.part' extension are ignored as well!
  468. * prevents unfinished put requests to be scanned
  469. *
  470. * @param string $file
  471. * @return boolean
  472. */
  473. public static function isPartialFile($file) {
  474. if (pathinfo($file, PATHINFO_EXTENSION) === 'part') {
  475. return true;
  476. }
  477. if (strpos($file, '.part/') !== false) {
  478. return true;
  479. }
  480. return false;
  481. }
  482. /**
  483. * walk over any folders that are not fully scanned yet and scan them
  484. */
  485. public function backgroundScan() {
  486. if ($this->storage->instanceOfStorage(Jail::class)) {
  487. // for jail storage wrappers (shares, groupfolders) we run the background scan on the source storage
  488. // this is mainly done because the jail wrapper doesn't implement `getIncomplete` (because it would be inefficient).
  489. //
  490. // Running the scan on the source storage might scan more than "needed", but the unscanned files outside the jail will
  491. // have to be scanned at some point anyway.
  492. $unJailedScanner = $this->storage->getUnjailedStorage()->getScanner();
  493. $unJailedScanner->backgroundScan();
  494. } else {
  495. if (!$this->cache->inCache('')) {
  496. // if the storage isn't in the cache yet, just scan the root completely
  497. $this->runBackgroundScanJob(function () {
  498. $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
  499. }, '');
  500. } else {
  501. $lastPath = null;
  502. // find any path marked as unscanned and run the scanner until no more paths are unscanned (or we get stuck)
  503. while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
  504. $this->runBackgroundScanJob(function () use ($path) {
  505. $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE);
  506. }, $path);
  507. // FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
  508. // to make this possible
  509. $lastPath = $path;
  510. }
  511. }
  512. }
  513. }
  514. private function runBackgroundScanJob(callable $callback, $path) {
  515. try {
  516. $callback();
  517. \OC_Hook::emit('Scanner', 'correctFolderSize', ['path' => $path]);
  518. if ($this->cacheActive && $this->cache instanceof Cache) {
  519. $this->cache->correctFolderSize($path, null, true);
  520. }
  521. } catch (\OCP\Files\StorageInvalidException $e) {
  522. // skip unavailable storages
  523. } catch (\OCP\Files\StorageNotAvailableException $e) {
  524. // skip unavailable storages
  525. } catch (\OCP\Files\ForbiddenException $e) {
  526. // skip forbidden storages
  527. } catch (\OCP\Lock\LockedException $e) {
  528. // skip unavailable storages
  529. }
  530. }
  531. /**
  532. * Set whether the cache is affected by scan operations
  533. *
  534. * @param boolean $active The active state of the cache
  535. */
  536. public function setCacheActive($active) {
  537. $this->cacheActive = $active;
  538. }
  539. }