fix(files_trashbin): Fix all IStorage return types

Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
provokateurin 2024-09-19 18:18:15 +02:00
parent 0451be763b
commit 0356e9e82f
No known key found for this signature in database
2 changed files with 11 additions and 25 deletions

View file

@ -48,14 +48,7 @@ class Storage extends Wrapper {
parent::__construct($parameters);
}
/**
* Deletes the given file by moving it into the trashbin.
*
* @param string $path path of file or folder to delete
*
* @return bool true if the operation succeeded, false otherwise
*/
public function unlink($path) {
public function unlink($path): bool {
if ($this->trashEnabled) {
try {
return $this->doDelete($path, 'unlink');
@ -72,14 +65,7 @@ class Storage extends Wrapper {
}
}
/**
* Deletes the given folder by moving it into the trashbin.
*
* @param string $path path of folder to delete
*
* @return bool true if the operation succeeded, false otherwise
*/
public function rmdir($path) {
public function rmdir($path): bool {
if ($this->trashEnabled) {
return $this->doDelete($path, 'rmdir');
} else {
@ -94,7 +80,7 @@ class Storage extends Wrapper {
* @param $path
* @return bool
*/
protected function shouldMoveToTrash($path) {
protected function shouldMoveToTrash($path): bool {
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$parts = explode('/', $normalized);
if (count($parts) < 4 || strpos($normalized, '/appdata_') === 0) {
@ -132,7 +118,7 @@ class Storage extends Wrapper {
* @param Node $node
* @return MoveToTrashEvent
*/
protected function createMoveToTrashEvent(Node $node) {
protected function createMoveToTrashEvent(Node $node): MoveToTrashEvent {
return new MoveToTrashEvent($node);
}
@ -144,7 +130,7 @@ class Storage extends Wrapper {
*
* @return bool true if the operation succeeded, false otherwise
*/
private function doDelete($path, $method) {
private function doDelete($path, $method): bool {
if (
!\OC::$server->getAppManager()->isEnabledForUser('files_trashbin')
|| (pathinfo($path, PATHINFO_EXTENSION) === 'part')
@ -170,7 +156,7 @@ class Storage extends Wrapper {
/**
* Setup the storage wrapper callback
*/
public static function setupStorage() {
public static function setupStorage(): void {
$trashManager = \OC::$server->get(ITrashManager::class);
$userManager = \OC::$server->get(IUserManager::class);
$logger = \OC::$server->get(LoggerInterface::class);
@ -195,7 +181,7 @@ class Storage extends Wrapper {
return $this->mountPoint;
}
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
$sourceIsTrashbin = $sourceStorage->instanceOfStorage(Storage::class);
try {
// the fallback for moving between storage involves a copy+delete
@ -219,11 +205,11 @@ class Storage extends Wrapper {
}
}
protected function disableTrash() {
protected function disableTrash(): void {
$this->trashEnabled = false;
}
protected function enableTrash() {
protected function enableTrash(): void {
$this->trashEnabled = true;
}
}

View file

@ -29,11 +29,11 @@ use Psr\Log\LoggerInterface;
use Test\Traits\MountProviderTrait;
class TemporaryNoCross extends Temporary {
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null) {
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null): bool {
return Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime);
}
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}
}