Bläddra i källkod

Merge pull request #26219 from nextcloud/relative-path-null

getRelativePath can return null
tags/v22.0.0beta1
Roeland Jago Douma 3 år sedan
förälder
incheckning
7c30d1aa2d
Inget konto är kopplat till bidragsgivarens mejladress

+ 1
- 1
apps/encryption/lib/Crypto/Encryption.php Visa fil

@@ -435,7 +435,7 @@ class Encryption implements IEncryptionModule {
public function shouldEncrypt($path) {
if ($this->util->shouldEncryptHomeStorage() === false) {
$storage = $this->util->getStorage($path);
if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
if ($storage && $storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
return false;
}
}

+ 1
- 1
apps/encryption/lib/Util.php Visa fil

@@ -191,7 +191,7 @@ class Util {
* get storage of path
*
* @param string $path
* @return \OC\Files\Storage\Storage
* @return \OC\Files\Storage\Storage|null
*/
public function getStorage($path) {
return $this->files->getMount($path)->getStorage();

+ 1
- 1
lib/private/Files/Filesystem.php Visa fil

@@ -312,7 +312,7 @@ class Filesystem {
* get the storage mounted at $mountPoint
*
* @param string $mountPoint
* @return \OC\Files\Storage\Storage
* @return \OC\Files\Storage\Storage|null
*/
public static function getStorage($mountPoint) {
if (!self::$mounts) {

+ 2
- 2
lib/private/Files/Mount/MountPoint.php Visa fil

@@ -39,7 +39,7 @@ use OCP\ILogger;

class MountPoint implements IMountPoint {
/**
* @var \OC\Files\Storage\Storage $storage
* @var \OC\Files\Storage\Storage|null $storage
*/
protected $storage = null;
protected $class;
@@ -167,7 +167,7 @@ class MountPoint implements IMountPoint {
}

/**
* @return \OC\Files\Storage\Storage
* @return \OC\Files\Storage\Storage|null
*/
public function getStorage() {
if (is_null($this->storage)) {

+ 2
- 2
lib/private/Files/Node/Folder.php Visa fil

@@ -76,7 +76,7 @@ class Folder extends Node implements \OCP\Files\Folder {

/**
* @param string $path
* @return string
* @return string|null
*/
public function getRelativePath($path) {
if ($this->path === '' or $this->path === '/') {
@@ -494,7 +494,7 @@ class Folder extends Node implements \OCP\Files\Folder {
$mounts[] = $this->getMountPoint();

$mounts = array_filter($mounts, function (IMountPoint $mount) {
return $mount->getStorage();
return $mount->getStorage() !== null;
});
$storageIds = array_map(function (IMountPoint $mount) {
return $mount->getStorage()->getCache()->getNumericStorageId();

+ 5
- 1
lib/private/Search/Result/File.php Visa fil

@@ -133,7 +133,11 @@ class File extends \OCP\Search\Result {
$userID = $userSession->getUser()->getUID();
self::$userFolderCache = \OC::$server->getUserFolder($userID);
}
return self::$userFolderCache->getRelativePath($path);
$relativePath = self::$userFolderCache->getRelativePath($path);
if ($relativePath === null) {
throw new \Exception("Search result not in user folder");
}
return $relativePath;
}

/**

+ 1
- 1
lib/public/Files/Folder.php Visa fil

@@ -55,7 +55,7 @@ interface Folder extends Node {
*
* @param string $path absolute path of an item in the folder
* @throws \OCP\Files\NotFoundException
* @return string
* @return string|null
* @since 6.0.0
*/
public function getRelativePath($path);

+ 1
- 1
lib/public/Files/Mount/IMountPoint.php Visa fil

@@ -48,7 +48,7 @@ interface IMountPoint {
/**
* Get the storage that is mounted
*
* @return \OC\Files\Storage\Storage
* @return \OC\Files\Storage\Storage|null
* @since 8.0.0
*/
public function getStorage();

Laddar…
Avbryt
Spara