Skip to content

Commit

Permalink
catch notfound and forbidden exception in smb::getmetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Feb 16, 2021
1 parent be0002d commit a1a987f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 25 deletions.
8 changes: 7 additions & 1 deletion apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,13 @@ public function touch($path, $mtime = null) {
}

public function getMetaData($path) {
$fileInfo = $this->getFileInfo($path);
try {
$fileInfo = $this->getFileInfo($path);
} catch (NotFoundException $e) {
return null;
} catch (ForbiddenException $e) {
return null;
}
if (!$fileInfo) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/External/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $loc
* @param int $parentId
* @param array | null $cacheData existing data in the cache for the file to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array an array of metadata of the scanned file
* @return array | null an array of metadata of the scanned file
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
try {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
*
* @param string $path path of the file for which to retrieve metadata
*
* @return array an array of metadata of the file
* @return array|null an array of metadata of the file
*/
public function getData($path) {
$data = parent::getData($path);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function setUseTransactions($useTransactions) {
* *
*
* @param string $path
* @return array an array of metadata of the file
* @return array|null an array of metadata of the file
*/
protected function getData($path) {
$data = $this->storage->getMetaData($path);
Expand All @@ -128,7 +128,7 @@ protected function getData($path) {
* @param array|null|false $cacheData existing data in the cache for the file to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @param null $data the metadata for the file, as returned by the storage
* @return array an array of metadata of the scanned file
* @return array|null an array of metadata of the scanned file
* @throws \OCP\Lock\LockedException
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
Expand Down Expand Up @@ -323,7 +323,7 @@ protected function updateCache($path, $data, $fileId = -1) {
* @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
* @return array|null 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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getStorageCache();

/**
* @param string $path
* @return array
* @return array|null
*/
public function getMetaData($path);

Expand Down
4 changes: 0 additions & 4 deletions lib/private/Files/Storage/Wrapper/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,6 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
return $result;
}

/**
* @param string $path
* @return array
*/
public function getMetaData($path) {
return $this->storage->getMetaData($this->findPathToUse($path));
}
Expand Down
4 changes: 0 additions & 4 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ private function modifyMetaData(string $path, array $data): array {
return $data;
}

/**
* @param string $path
* @return array
*/
public function getMetaData($path) {
$data = $this->storage->getMetaData($path);
if (is_null($data)) {
Expand Down
4 changes: 0 additions & 4 deletions lib/private/Files/Storage/Wrapper/Jail.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ public function getETag($path) {
return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));
}

/**
* @param string $path
* @return array
*/
public function getMetaData($path) {
return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path));
}
Expand Down
4 changes: 0 additions & 4 deletions lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,6 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}

/**
* @param string $path
* @return array
*/
public function getMetaData($path) {
return $this->getWrapperStorage()->getMetaData($path);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Files/Cache/IScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface IScanner {
* @param int $parentId
* @param array | null $cacheData existing data in the cache for the file to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array an array of metadata of the scanned file
* @return array | null an array of metadata of the scanned file
* @throws \OC\ServerNotAvailableException
* @throws \OCP\Lock\LockedException
* @since 9.0.0
Expand All @@ -59,7 +59,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData =
* @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
* @return array | null an array of the meta data of the scanned file or folder
* @since 9.0.0
*/
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true);
Expand Down

0 comments on commit a1a987f

Please sign in to comment.