public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { $sourceScanner = $this->getSourceScanner(); if ($sourceScanner instanceof NoopScanner) { return []; } else { return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock); } }
public function testScanRemovedFile() { $this->fillTestFolders(); $this->scanner->scan(''); $this->assertTrue($this->cache->inCache('folder/bar.txt')); $this->storage->unlink('folder/bar.txt'); $this->scanner->scanFile('folder/bar.txt'); $this->assertFalse($this->cache->inCache('folder/bar.txt')); }
/** * Update the cache for changes to $path * * @param string $path * @param ICacheEntry $cachedData */ public function update($path, $cachedData) { if ($this->storage->is_dir($path)) { $this->scanner->scan($path, Scanner::SCAN_SHALLOW); } else { $this->scanner->scanFile($path); } if ($cachedData['mimetype'] === 'httpd/unix-directory') { $this->cleanFolder($path); } $this->cache->correctFolderSize($path); }
/** * Scan a single file and store it in the cache. * If an exception happened while accessing the external storage, * the storage will be checked for availability and removed * if it is not available any more. * * @param string $file file to scan * @param int $reuseExisting * @param int $parentId * @param array | null $cacheData existing data in the cache for the file to be scanned * @return array an array of metadata of the scanned file */ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null) { try { return parent::scanFile($file, $reuseExisting); } catch (ForbiddenException $e) { $this->storage->checkStorageAvailability(); } catch (NotFoundException $e) { // if the storage isn't found, the call to // checkStorageAvailable() will verify it and remove it // if appropriate $this->storage->checkStorageAvailability(); } catch (StorageInvalidException $e) { $this->storage->checkStorageAvailability(); } catch (StorageNotAvailableException $e) { $this->storage->checkStorageAvailability(); } }