Loading lib/Filesystem/StorageWrapper.php +21 −21 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ namespace OCA\EcloudAccounts\Filesystem; use OC\Files\Cache\Cache; use OC\Files\Storage\Storage; use OC\Files\Storage\Wrapper\Wrapper; use OCP\Files\ForbiddenException; use OC\ServiceUnavailableException; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; Loading @@ -20,10 +20,10 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { } /** * @throws ForbiddenException * @throws ServiceUnavailableException */ protected function checkFileAccess(string $path, bool $isDir = false): void { throw new ForbiddenException('Access denied', false); throw new ServiceUnavailableException('Access denied'); } /* Loading @@ -35,7 +35,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function mkdir($path) { $this->checkFileAccess($path, true); Loading @@ -46,7 +46,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function rmdir($path) { $this->checkFileAccess($path, true); Loading @@ -61,7 +61,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isCreatable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -75,7 +75,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isReadable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -89,7 +89,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isUpdatable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -103,7 +103,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isDeletable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -111,7 +111,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function getPermissions($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return $this->mask; } } Loading @@ -121,7 +121,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return string * @throws ForbiddenException * @throws ServiceUnavailableException */ public function file_get_contents($path) { $this->checkFileAccess($path); Loading @@ -133,7 +133,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param string $data * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function file_put_contents($path, $data) { $this->checkFileAccess($path); Loading @@ -144,7 +144,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function unlink($path) { $this->checkFileAccess($path); Loading @@ -156,7 +156,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path1 * @param string $path2 * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function rename($path1, $path2) { $this->checkFileAccess($path1); Loading @@ -169,7 +169,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path1 * @param string $path2 * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function copy($path1, $path2) { $this->checkFileAccess($path1); Loading @@ -182,7 +182,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param string $mode * @return resource * @throws ForbiddenException * @throws ServiceUnavailableException */ public function fopen($path, $mode) { $this->checkFileAccess($path); Loading @@ -195,7 +195,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param int $mtime * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function touch($path, $mtime = null) { $this->checkFileAccess($path); Loading Loading @@ -223,7 +223,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return array * @throws ForbiddenException * @throws ServiceUnavailableException */ public function getDirectDownload($path) { $this->checkFileAccess($path); Loading @@ -234,7 +234,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $sourceInternalPath * @param string $targetInternalPath * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { $this->checkFileAccess($targetInternalPath); Loading @@ -245,14 +245,14 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $sourceInternalPath * @param string $targetInternalPath * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { $this->checkFileAccess($targetInternalPath); } /** * @throws ForbiddenException * @throws ServiceUnavailableException */ public function writeStream(string $path, $stream, ?int $size = null): int { $this->checkFileAccess($path); Loading Loading
lib/Filesystem/StorageWrapper.php +21 −21 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ namespace OCA\EcloudAccounts\Filesystem; use OC\Files\Cache\Cache; use OC\Files\Storage\Storage; use OC\Files\Storage\Wrapper\Wrapper; use OCP\Files\ForbiddenException; use OC\ServiceUnavailableException; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; Loading @@ -20,10 +20,10 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { } /** * @throws ForbiddenException * @throws ServiceUnavailableException */ protected function checkFileAccess(string $path, bool $isDir = false): void { throw new ForbiddenException('Access denied', false); throw new ServiceUnavailableException('Access denied'); } /* Loading @@ -35,7 +35,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function mkdir($path) { $this->checkFileAccess($path, true); Loading @@ -46,7 +46,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function rmdir($path) { $this->checkFileAccess($path, true); Loading @@ -61,7 +61,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isCreatable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -75,7 +75,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isReadable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -89,7 +89,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isUpdatable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -103,7 +103,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function isDeletable($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return false; } } Loading @@ -111,7 +111,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { public function getPermissions($path) { try { $this->checkFileAccess($path); } catch (ForbiddenException $e) { } catch (ServiceUnavailableException $e) { return $this->mask; } } Loading @@ -121,7 +121,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return string * @throws ForbiddenException * @throws ServiceUnavailableException */ public function file_get_contents($path) { $this->checkFileAccess($path); Loading @@ -133,7 +133,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param string $data * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function file_put_contents($path, $data) { $this->checkFileAccess($path); Loading @@ -144,7 +144,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function unlink($path) { $this->checkFileAccess($path); Loading @@ -156,7 +156,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path1 * @param string $path2 * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function rename($path1, $path2) { $this->checkFileAccess($path1); Loading @@ -169,7 +169,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path1 * @param string $path2 * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function copy($path1, $path2) { $this->checkFileAccess($path1); Loading @@ -182,7 +182,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param string $mode * @return resource * @throws ForbiddenException * @throws ServiceUnavailableException */ public function fopen($path, $mode) { $this->checkFileAccess($path); Loading @@ -195,7 +195,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $path * @param int $mtime * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function touch($path, $mtime = null) { $this->checkFileAccess($path); Loading Loading @@ -223,7 +223,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * * @param string $path * @return array * @throws ForbiddenException * @throws ServiceUnavailableException */ public function getDirectDownload($path) { $this->checkFileAccess($path); Loading @@ -234,7 +234,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $sourceInternalPath * @param string $targetInternalPath * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { $this->checkFileAccess($targetInternalPath); Loading @@ -245,14 +245,14 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage { * @param string $sourceInternalPath * @param string $targetInternalPath * @return bool * @throws ForbiddenException * @throws ServiceUnavailableException */ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { $this->checkFileAccess($targetInternalPath); } /** * @throws ForbiddenException * @throws ServiceUnavailableException */ public function writeStream(string $path, $stream, ?int $size = null): int { $this->checkFileAccess($path); Loading