Skip to content

Commit

Permalink
chore: psalm fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Dec 12, 2024
1 parent 4d0e5a1 commit 5a0bbb3
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 106 deletions.
5 changes: 3 additions & 2 deletions lib/Mount/GroupFolderStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OC\Files\ObjectStore\ObjectStoreScanner;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Quota;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\IUser;
use OCP\IUserSession;
Expand All @@ -33,8 +34,8 @@ class GroupFolderStorage extends Quota {
private int $folderId;
private ?ICacheEntry $rootEntry;
private IUserSession $userSession;
private ?IUser $mountOwner = null;
/** @var RootEntryCache|null */
private ?IUser $mountOwner;
/** @var ICache|null */
public $cache = null;

public function __construct($parameters) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function getTrashMount(

$storage = $this->getRootFolder()->getStorage();

$storage->setOwner($user?->getUID());
$storage->setOwner($user->getUID());

$trashPath = $this->getRootFolder()->getInternalPath() . '/trash/' . $id;

Expand Down
10 changes: 8 additions & 2 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace OCA\GroupFolders\Trash;

use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\Storage\Wrapper\Jail;
use OCA\Files_Trashbin\Expiration;
Expand Down Expand Up @@ -309,9 +310,11 @@ private function moveFromEncryptedStorage(IStorage $sourceStorage, IStorage $tar
$sourceStorage = $sourceStorage->getWrapperStorage();
}

/** @psalm-suppress TooManyArguments */
$result = $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
if ($result) {
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
// hacky workaround to make sure we don't rely on a newer minor version
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class) && is_callable([$sourceStorage, 'setPreserveCacheOnDelete'])) {
/** @var ObjectStoreStorage $sourceStorage */
$sourceStorage->setPreserveCacheOnDelete(true);
}
Expand All @@ -322,7 +325,7 @@ private function moveFromEncryptedStorage(IStorage $sourceStorage, IStorage $tar
$result = $sourceStorage->unlink($sourceInternalPath);
}
} finally {
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class) && is_callable([$sourceStorage, 'setPreserveCacheOnDelete'])) {
/** @var ObjectStoreStorage $sourceStorage */
$sourceStorage->setPreserveCacheOnDelete(false);
}
Expand Down Expand Up @@ -355,6 +358,7 @@ private function getNodeForTrashItem(IUser $user, ITrashItem $trashItem): ?Node
$folders = $this->folderManager->getFoldersForUser($user);
foreach ($folders as $groupFolder) {
if ($groupFolder['folder_id'] === $folderId) {
/** @var Folder $trashRoot */
$trashRoot = $this->rootFolder->get('/' . $user->getUID() . '/files_trashbin/groupfolders/' . $folderId);
try {
$node = $trashRoot->get($path);
Expand Down Expand Up @@ -421,6 +425,8 @@ private function getTrashForFolders(IUser $user, array $folders): array {
// ensure the trash folder exists
$this->getTrashFolder($folderId);


/** @var Folder $trashFolder */
$trashFolder = $this->rootFolder->get('/' . $user->getUID() . '/files_trashbin/groupfolders/' . $folderId);
$content = $trashFolder->getDirectoryListing();
$this->aclManagerFactory->getACLManager($user)->preloadRulesForFolder($this->getUnJailedPath($trashFolder));
Expand Down
Loading

0 comments on commit 5a0bbb3

Please sign in to comment.