fix(Storage): Document getOwner() can return false

Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
provokateurin 2024-09-16 16:00:30 +02:00
parent c256518ab3
commit 8ca6fcace7
No known key found for this signature in database
13 changed files with 15 additions and 48 deletions

View file

@ -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) {

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -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));
}

View file

@ -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);
}

View file

@ -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');

View file

@ -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) {

View file

@ -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);

View file

@ -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 {