Skip to content

Commit

Permalink
fix(ACLStorageWrapper): Fix return types
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Sep 26, 2024
1 parent 294a6f8 commit b504980
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/ACL/ACLStorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace OCA\GroupFolders\ACL;

use Icewind\Streams\IteratorDirectory;
use OC\Files\Cache\Scanner;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Constants;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\IScanner;
use OCP\Files\Storage\IStorage;

class ACLStorageWrapper extends Wrapper {
Expand Down Expand Up @@ -204,7 +204,7 @@ public function getMetaData($path): ?array {
* @param string $path
* @param ?IStorage $storage
*/
public function getScanner($path = '', $storage = null): Scanner {
public function getScanner($path = '', $storage = null): IScanner {
if (!$storage) {
$storage = $this->storage;
}
Expand All @@ -222,15 +222,15 @@ public function is_file($path): bool {
parent::is_file($path);
}

public function stat($path): array|bool {
public function stat($path): array|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}

return parent::stat($path);
}

public function filetype($path): string|bool {
public function filetype($path): string|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}
Expand All @@ -251,7 +251,7 @@ public function file_exists($path): bool {
parent::file_exists($path);
}

public function filemtime($path): int|bool {
public function filemtime($path): int|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}
Expand All @@ -267,15 +267,15 @@ public function file_get_contents($path): string|false {
return parent::file_get_contents($path);
}

public function getMimeType($path): string|bool {
public function getMimeType($path): string|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}

return parent::getMimeType($path);
}

public function hash($type, $path, $raw = false): string|bool {
public function hash($type, $path, $raw = false): string|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}
Expand All @@ -291,16 +291,20 @@ public function getETag($path): string|false {
return parent::getETag($path);
}

public function getDirectDownload($path): array|bool {
public function getDirectDownload($path): array|false {
if (!$this->checkPermissions($path, Constants::PERMISSION_READ)) {
return false;
}

return parent::getDirectDownload($path);
}

public function getDirectoryContent($directory): \Traversable {
foreach ($this->getWrapperStorage()->getDirectoryContent($directory) as $data) {
public function getDirectoryContent($directory): \Traversable|false {
$content = $this->getWrapperStorage()->getDirectoryContent($directory);
if ($content === false) {
return false;
}
foreach ($content as $data) {
$data['scan_permissions'] ??= $data['permissions'];
$data['permissions'] &= $this->getACLPermissionsForPath(rtrim($directory, '/') . '/' . $data['name']);

Expand Down
2 changes: 2 additions & 0 deletions tests/ACL/ACLScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OCA\groupfolders\tests\ACL;

use OC\Files\Cache\Cache;
use OC\Files\Storage\Temporary;
use OCA\GroupFolders\ACL\ACLManager;
use OCA\GroupFolders\ACL\ACLStorageWrapper;
Expand All @@ -33,6 +34,7 @@ public function testScanAclStorage(): void {
$baseStorage->mkdir('foo');
$baseStorage->mkdir('foo/bar');
$baseStorage->mkdir('foo/bar/asd');
/** @var Cache $cache */
$cache = $baseStorage->getCache();
$baseStorage->getScanner()->scan('');

Expand Down

0 comments on commit b504980

Please sign in to comment.