/** * check $path for updates * * @param string $path */ public function checkUpdate($path) { $cachedEntry = $this->cache->get($path); if ($this->storage->hasUpdated($path, $cachedEntry['mtime'])) { if ($this->storage->is_dir($path)) { $this->scanner->scan($path, Scanner::SCAN_SHALLOW); } else { $this->scanner->scanFile($path); } if ($cachedEntry['mimetype'] === 'httpd/unix-directory') { $this->cleanFolder($path); } $this->cache->correctFolderSize($path); } }
/** * Check if the cache for $path needs to be updated * * @param string $path * @param ICacheEntry $cachedData * @return bool */ public function needsUpdate($path, $cachedData) { if ($this->watchPolicy === self::CHECK_ALWAYS or $this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false) { $this->checkedPaths[] = $path; return $this->storage->hasUpdated($path, $cachedData['storage_mtime']); } return false; }
/** * check $path for updates * * @param string $path * @return boolean|array true if path was updated, otherwise the cached data is returned */ public function checkUpdate($path) { if ($this->watchPolicy === self::CHECK_ALWAYS or $this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false) { $cachedEntry = $this->cache->get($path); $this->checkedPaths[] = $path; if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) { if ($this->storage->is_dir($path)) { $this->scanner->scan($path, Scanner::SCAN_SHALLOW); } else { $this->scanner->scanFile($path); } if ($cachedEntry['mimetype'] === 'httpd/unix-directory') { $this->cleanFolder($path); } $this->cache->correctFolderSize($path); return true; } return $cachedEntry; } else { return false; } }
/** * check if a file or folder has been updated since $time * * @param string $path * @param int $time * @return bool * * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. * returning true for other changes in the folder is optional */ public function hasUpdated($path, $time) { return $this->storage->hasUpdated($path, $time); }