Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87252701 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

rnd: return StorageNotAvailableException

parent 13d32a6b
Loading
Loading
Loading
Loading
+21 −20
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Files\Storage\IStorage;
use OCP\Files\Storage\IWriteStreamStorage;
use OCP\Files\StorageNotAvailableException;

class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	/**
@@ -19,10 +20,10 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	}

	/**
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	protected function checkFileAccess(string $path, bool $isDir = false): void {
		throw new \Exception('Service unavailable', 503);
		throw new StorageNotAvailableException('Service unavailable');
	}

	/*
@@ -34,7 +35,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 *
	 * @param string $path
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function mkdir($path) {
		$this->checkFileAccess($path, true);
@@ -45,7 +46,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 *
	 * @param string $path
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function rmdir($path) {
		$this->checkFileAccess($path, true);
@@ -60,7 +61,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	public function isCreatable($path) {
		try {
			$this->checkFileAccess($path);
		} catch (\Exception $e) {
		} catch (StorageNotAvailableException $e) {
			return false;
		}
	}
@@ -74,7 +75,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	public function isReadable($path) {
		try {
			$this->checkFileAccess($path);
		} catch (\Exception $e) {
		} catch (StorageNotAvailableException $e) {
			return false;
		}
	}
@@ -88,7 +89,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	public function isUpdatable($path) {
		try {
			$this->checkFileAccess($path);
		} catch (\Exception $e) {
		} catch (StorageNotAvailableException $e) {
			return false;
		}
	}
@@ -102,7 +103,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	public function isDeletable($path) {
		try {
			$this->checkFileAccess($path);
		} catch (\Exception $e) {
		} catch (StorageNotAvailableException $e) {
			return false;
		}
	}
@@ -110,7 +111,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	public function getPermissions($path) {
		try {
			$this->checkFileAccess($path);
		} catch (\Exception $e) {
		} catch (StorageNotAvailableException $e) {
			return $this->mask;
		}
	}
@@ -120,7 +121,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 *
	 * @param string $path
	 * @return string
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function file_get_contents($path) {
		$this->checkFileAccess($path);
@@ -132,7 +133,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $path
	 * @param string $data
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function file_put_contents($path, $data) {
		$this->checkFileAccess($path);
@@ -143,7 +144,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 *
	 * @param string $path
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function unlink($path) {
		$this->checkFileAccess($path);
@@ -155,7 +156,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $path1
	 * @param string $path2
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function rename($path1, $path2) {
		$this->checkFileAccess($path1);
@@ -168,7 +169,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $path1
	 * @param string $path2
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function copy($path1, $path2) {
		$this->checkFileAccess($path1);
@@ -181,7 +182,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $path
	 * @param string $mode
	 * @return resource
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function fopen($path, $mode) {
		$this->checkFileAccess($path);
@@ -194,7 +195,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $path
	 * @param int $mtime
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function touch($path, $mtime = null) {
		$this->checkFileAccess($path);
@@ -222,7 +223,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 *
	 * @param string $path
	 * @return array
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function getDirectDownload($path) {
		$this->checkFileAccess($path);
@@ -233,7 +234,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $sourceInternalPath
	 * @param string $targetInternalPath
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
		$this->checkFileAccess($targetInternalPath);
@@ -244,14 +245,14 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
	 * @param string $sourceInternalPath
	 * @param string $targetInternalPath
	 * @return bool
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
		$this->checkFileAccess($targetInternalPath);
	}

	/**
	 * @throws \Exception
	 * @throws StorageNotAvailableException
	 */
	public function writeStream(string $path, $stream, ?int $size = null): int {
		$this->checkFileAccess($path);