mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
fix(Storage): Document getOwner() can return false
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
c256518ab3
commit
8ca6fcace7
13 changed files with 15 additions and 48 deletions
|
|
@ -26,7 +26,7 @@ class PublicOwnerWrapper extends Wrapper {
|
|||
$this->owner = $arguments['owner'];
|
||||
}
|
||||
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
$owner = parent::getOwner($path);
|
||||
|
||||
if ($owner === null || $owner === false) {
|
||||
|
|
|
|||
2
apps/files_sharing/lib/External/Storage.php
vendored
2
apps/files_sharing/lib/External/Storage.php
vendored
|
|
@ -345,7 +345,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
|
|||
return json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->cloudId->getDisplayId();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
|
|||
return new \OCA\Files_Sharing\Scanner($storage);
|
||||
}
|
||||
|
||||
public function getOwner($path): string {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->superShare->getShareOwner();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
|
|||
return 'object::user:' . $this->user->getUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the owner of a path
|
||||
*
|
||||
* @param string $path The path to get the owner
|
||||
* @return string uid
|
||||
*/
|
||||
public function getOwner($path): string {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->user->getUID();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -390,13 +390,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
return $this->getCache($storage)->getStorageCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the owner of a path
|
||||
*
|
||||
* @param string $path The path to get the owner
|
||||
* @return string|false uid or false
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
if ($this->owner === null) {
|
||||
$this->owner = \OC_User::getUser();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,13 +83,7 @@ class Home extends Local implements \OCP\Files\IHomeStorage {
|
|||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the owner of a path
|
||||
*
|
||||
* @param string $path The path to get the owner
|
||||
* @return string uid or false
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->user->getUID();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,12 +373,12 @@ class Availability extends Wrapper {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
try {
|
||||
return parent::getOwner($path);
|
||||
} catch (StorageNotAvailableException $e) {
|
||||
$this->setUnavailable($e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -370,13 +370,7 @@ class Jail extends Wrapper {
|
|||
return new CacheJail($sourceCache, $this->rootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the user id of the owner of a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,14 +381,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
|
|||
return $this->getWrapperStorage()->getScanner($path, $storage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the user id of the owner of a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
public function getOwner($path): string|false {
|
||||
return $this->getWrapperStorage()->getOwner($path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1676,11 +1676,9 @@ class View {
|
|||
/**
|
||||
* Get the owner for a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string the user id of the owner
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function getOwner($path) {
|
||||
public function getOwner(string $path): string {
|
||||
$info = $this->getFileInfo($path);
|
||||
if (!$info) {
|
||||
throw new NotFoundException($path . ' not found while trying to get owner');
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ class NullStorage extends Common {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getOwner($path) {
|
||||
return null;
|
||||
public function getOwner($path): string|false {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCache($path = '', $storage = null) {
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ interface IStorage {
|
|||
|
||||
/**
|
||||
* @param string $path path for which to retrieve the owner
|
||||
* @return string
|
||||
* @return string|false
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function getOwner($path);
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ class NullStorageTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetOwner(): void {
|
||||
$this->assertNull($this->storage->getOwner('foo'));
|
||||
$this->assertFalse($this->storage->getOwner('foo'));
|
||||
}
|
||||
|
||||
public function testGetCache(): void {
|
||||
|
|
|
|||
Loading…
Reference in a new issue