Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>tags/v27.0.0beta1
@@ -78,7 +78,7 @@ interface IVersionBackend { | |||
* Open the file for reading | |||
* | |||
* @param IVersion $version | |||
* @return resource | |||
* @return resource|false | |||
* @throws NotFoundException | |||
* @since 15.0.0 | |||
*/ |
@@ -420,11 +420,8 @@ class Filesystem { | |||
* return the path to a local version of the file | |||
* we need this because we can't know if a file is stored local or not from | |||
* outside the filestorage and for some purposes a local file is needed | |||
* | |||
* @param string $path | |||
* @return string | |||
*/ | |||
public static function getLocalFile($path) { | |||
public static function getLocalFile(string $path): string|false { | |||
return self::$defaultInstance->getLocalFile($path); | |||
} | |||
@@ -761,11 +758,8 @@ class Filesystem { | |||
/** | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string | |||
*/ | |||
public static function getETag($path) { | |||
public static function getETag(string $path): string|false { | |||
return self::$defaultInstance->getETag($path); | |||
} | |||
} |
@@ -196,7 +196,7 @@ class NewSimpleFile implements ISimpleFile { | |||
/** | |||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen | |||
* | |||
* @return resource | |||
* @return resource|false | |||
* @throws \OCP\Files\NotPermittedException | |||
* @since 14.0.0 | |||
*/ |
@@ -150,7 +150,7 @@ class SimpleFile implements ISimpleFile { | |||
/** | |||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen | |||
* | |||
* @return resource | |||
* @return resource|false | |||
* @throws \OCP\Files\NotPermittedException | |||
* @since 14.0.0 | |||
*/ |
@@ -35,14 +35,10 @@ namespace OC\Files\Storage; | |||
* in classes which extend it, e.g. $this->stat() . | |||
*/ | |||
trait LocalTempFileTrait { | |||
/** @var string[] */ | |||
protected $cachedFiles = []; | |||
/** @var array<string,string|false> */ | |||
protected array $cachedFiles = []; | |||
/** | |||
* @param string $path | |||
* @return string | |||
*/ | |||
protected function getCachedFile($path) { | |||
protected function getCachedFile(string $path): string|false { | |||
if (!isset($this->cachedFiles[$path])) { | |||
$this->cachedFiles[$path] = $this->toTmpFile($path); | |||
} | |||
@@ -56,11 +52,7 @@ trait LocalTempFileTrait { | |||
unset($this->cachedFiles[$path]); | |||
} | |||
/** | |||
* @param string $path | |||
* @return string | |||
*/ | |||
protected function toTmpFile($path) { //no longer in the storage api, still useful here | |||
protected function toTmpFile(string $path): string|false { //no longer in the storage api, still useful here | |||
$source = $this->fopen($path, 'r'); | |||
if (!$source) { | |||
return false; |
@@ -159,7 +159,7 @@ class Encoding extends Wrapper { | |||
* see https://www.php.net/manual/en/function.opendir.php | |||
* | |||
* @param string $path | |||
* @return resource|bool | |||
* @return resource|false | |||
*/ | |||
public function opendir($path) { | |||
$handle = $this->storage->opendir($this->findPathToUse($path)); | |||
@@ -429,7 +429,7 @@ class Encoding extends Wrapper { | |||
* The local version of the file can be temporary and doesn't have to be persistent across requests | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getLocalFile($path) { | |||
return $this->storage->getLocalFile($this->findPathToUse($path)); | |||
@@ -481,7 +481,7 @@ class Encoding extends Wrapper { | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getETag($path) { | |||
return $this->storage->getETag($this->findPathToUse($path)); |
@@ -46,7 +46,7 @@ class EncodingDirectoryWrapper extends DirectoryWrapper { | |||
/** | |||
* @param resource $source | |||
* @param callable $filter | |||
* @return resource|bool | |||
* @return resource|false | |||
*/ | |||
public static function wrap($source) { | |||
return self::wrapSource($source, [ |
@@ -108,7 +108,7 @@ class Jail extends Wrapper { | |||
* see https://www.php.net/manual/en/function.opendir.php | |||
* | |||
* @param string $path | |||
* @return resource|bool | |||
* @return resource|false | |||
*/ | |||
public function opendir($path) { | |||
return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path)); | |||
@@ -368,7 +368,7 @@ class Jail extends Wrapper { | |||
* The local version of the file can be temporary and doesn't have to be persistent across requests | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getLocalFile($path) { | |||
return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path)); | |||
@@ -431,7 +431,7 @@ class Jail extends Wrapper { | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getETag($path) { | |||
return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path)); |
@@ -98,7 +98,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea | |||
* see https://www.php.net/manual/en/function.opendir.php | |||
* | |||
* @param string $path | |||
* @return resource|bool | |||
* @return resource|false | |||
*/ | |||
public function opendir($path) { | |||
return $this->getWrapperStorage()->opendir($path); | |||
@@ -358,7 +358,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea | |||
* The local version of the file can be temporary and doesn't have to be persistent across requests | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getLocalFile($path) { | |||
return $this->getWrapperStorage()->getLocalFile($path); | |||
@@ -456,7 +456,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
*/ | |||
public function getETag($path) { | |||
return $this->getWrapperStorage()->getETag($path); |
@@ -223,7 +223,7 @@ class View { | |||
* | |||
* @param string $path | |||
*/ | |||
public function getLocalFile($path): string|bool { | |||
public function getLocalFile($path): string|false { | |||
$parent = substr($path, 0, strrpos($path, '/') ?: 0); | |||
$path = $this->getAbsolutePath($path); | |||
[$storage, $internalPath] = Filesystem::resolvePath($path); | |||
@@ -333,7 +333,7 @@ class View { | |||
/** | |||
* @param string $path | |||
* @return resource | |||
* @return resource|false | |||
*/ | |||
public function opendir($path) { | |||
return $this->basicOperation('opendir', $path, ['read']); | |||
@@ -1680,14 +1680,14 @@ class View { | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string | |||
* @return string|false | |||
*/ | |||
public function getETag($path) { | |||
[$storage, $internalPath] = $this->resolvePath($path); | |||
if ($storage) { | |||
return $storage->getETag($internalPath); | |||
} else { | |||
return null; | |||
return false; | |||
} | |||
} | |||
@@ -33,6 +33,7 @@ declare(strict_types=1); | |||
namespace OC\Security; | |||
use OC\Files\Filesystem; | |||
use OC\Files\View; | |||
use OCP\ICertificate; | |||
use OCP\ICertificateManager; | |||
use OCP\IConfig; | |||
@@ -43,24 +44,14 @@ use Psr\Log\LoggerInterface; | |||
* Manage trusted certificates for users | |||
*/ | |||
class CertificateManager implements ICertificateManager { | |||
/** | |||
* @var \OC\Files\View | |||
*/ | |||
protected $view; | |||
/** | |||
* @var IConfig | |||
*/ | |||
protected $config; | |||
protected View $view; | |||
protected IConfig $config; | |||
protected LoggerInterface $logger; | |||
/** @var ISecureRandom */ | |||
protected $random; | |||
protected ISecureRandom $random; | |||
private ?string $bundlePath = null; | |||
public function __construct(\OC\Files\View $view, | |||
public function __construct(View $view, | |||
IConfig $config, | |||
LoggerInterface $logger, | |||
ISecureRandom $random) { | |||
@@ -233,8 +224,7 @@ class CertificateManager implements ICertificateManager { | |||
/** | |||
* Get the full local path to the certificate bundle | |||
* | |||
* @return string | |||
* @throws \Exception when getting bundle path fails | |||
*/ | |||
public function getAbsoluteBundlePath(): string { | |||
try { | |||
@@ -247,7 +237,10 @@ class CertificateManager implements ICertificateManager { | |||
$this->createCertificateBundle(); | |||
} | |||
$this->bundlePath = $this->view->getLocalFile($this->getCertificateBundle()); | |||
$this->bundlePath = $this->view->getLocalFile($this->getCertificateBundle()) ?: null; | |||
} | |||
if ($this->bundlePath === null) { | |||
throw new \Exception('Failed to get absolute bundle path'); | |||
} | |||
return $this->bundlePath; | |||
} catch (\Exception $e) { | |||
@@ -255,9 +248,6 @@ class CertificateManager implements ICertificateManager { | |||
} | |||
} | |||
/** | |||
* @return string | |||
*/ | |||
private function getPathToCertificates(): string { | |||
return '/files_external/'; | |||
} |
@@ -439,7 +439,7 @@ class Server extends ServerContainer implements IServerContainer { | |||
return $c->get('SystemTagManagerFactory')->getObjectMapper(); | |||
}); | |||
$this->registerService('RootFolder', function (ContainerInterface $c) { | |||
$manager = \OC\Files\Filesystem::getMountManager(null); | |||
$manager = \OC\Files\Filesystem::getMountManager(); | |||
$view = new View(); | |||
$root = new Root( | |||
$manager, |
@@ -107,7 +107,7 @@ interface ISimpleFile { | |||
/** | |||
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen | |||
* | |||
* @return resource | |||
* @return resource|false | |||
* @throws \OCP\Files\NotPermittedException | |||
* @since 14.0.0 | |||
*/ |
@@ -88,7 +88,7 @@ interface Storage extends IStorage { | |||
* see https://www.php.net/manual/en/function.opendir.php | |||
* | |||
* @param string $path | |||
* @return resource|bool | |||
* @return resource|false | |||
* @since 6.0.0 | |||
*/ | |||
public function opendir($path); | |||
@@ -326,7 +326,7 @@ interface Storage extends IStorage { | |||
* The local version of the file can be temporary and doesn't have to be persistent across requests | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
* @since 6.0.0 | |||
*/ | |||
public function getLocalFile($path); | |||
@@ -348,7 +348,7 @@ interface Storage extends IStorage { | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
* @since 6.0.0 | |||
*/ | |||
public function getETag($path); |
@@ -85,7 +85,7 @@ interface IStorage { | |||
* see https://www.php.net/manual/en/function.opendir.php | |||
* | |||
* @param string $path | |||
* @return resource|bool | |||
* @return resource|false | |||
* @since 9.0.0 | |||
*/ | |||
public function opendir($path); | |||
@@ -314,7 +314,7 @@ interface IStorage { | |||
* The local version of the file can be temporary and doesn't have to be persistent across requests | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
* @since 9.0.0 | |||
*/ | |||
public function getLocalFile($path); | |||
@@ -336,7 +336,7 @@ interface IStorage { | |||
* get the ETag for a file or folder | |||
* | |||
* @param string $path | |||
* @return string|bool | |||
* @return string|false | |||
* @since 9.0.0 | |||
*/ | |||
public function getETag($path); |