/** * scan a folder and all it's children * * @param string $path * @param bool $recursive * @param int $reuse * @param bool $lock set to false to disable getting an additional read lock during scanning * @return array an array of the meta data of the scanned file or folder */ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { if ($reuse === -1) { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } if ($lock) { $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } $data = $this->scanFile($path, $reuse, -1, null, $lock); if ($data and $data['mimetype'] === 'httpd/unix-directory') { $size = $this->scanChildren($path, $recursive, $reuse, $data, $lock); $data['size'] = $size; } if ($lock) { $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } return $data; }
/** * scan a folder and all it's children * * @param string $path * @param bool $recursive * @param int $reuse * @param bool $lock set to false to disable getting an additional read lock during scanning * @return array an array of the meta data of the scanned file or folder */ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { if ($reuse === -1) { $reuse = $recursive === self::SCAN_SHALLOW ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } if ($lock) { if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) { $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } $data = $this->scanFile($path, $reuse, -1, null, $lock); if ($data and $data['mimetype'] === 'httpd/unix-directory') { $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock); $data['size'] = $size; } if ($lock) { if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) { $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); } } return $data; }
/** * @param string $path * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider */ public function releaseLock($path, $type, ILockingProvider $provider) { if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) { $this->storage->releaseLock($path, $type, $provider); } }
/** * @param string $path * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider */ public function releaseLock($path, $type, ILockingProvider $provider) { $this->storage->releaseLock($path, $type, $provider); }