Skip to content

Commit d6aca02

Browse files
icewind1991backportbot[bot]
authored andcommitted
chore: psalm fixes
Signed-off-by: Robin Appelman <[email protected]> [skip ci]
1 parent cc8f8b6 commit d6aca02

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

lib/Mount/GroupFolderStorage.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use OC\Files\ObjectStore\ObjectStoreScanner;
2626
use OC\Files\ObjectStore\ObjectStoreStorage;
2727
use OC\Files\Storage\Wrapper\Quota;
28+
use OCP\Files\Cache\ICache;
2829
use OCP\Files\Cache\ICacheEntry;
2930
use OCP\IUser;
3031
use OCP\IUserSession;
@@ -33,8 +34,8 @@ class GroupFolderStorage extends Quota {
3334
private int $folderId;
3435
private ?ICacheEntry $rootEntry;
3536
private IUserSession $userSession;
36-
private ?IUser $mountOwner = null;
37-
/** @var RootEntryCache|null */
37+
private ?IUser $mountOwner;
38+
/** @var ICache|null */
3839
public $cache = null;
3940

4041
public function __construct($parameters) {

lib/Mount/MountProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function getTrashMount(
279279

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

282-
$storage->setOwner($user?->getUID());
282+
$storage->setOwner($user->getUID());
283283

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

lib/Trash/TrashBackend.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace OCA\GroupFolders\Trash;
2323

2424
use OC\Encryption\Exceptions\DecryptionFailedException;
25+
use OC\Files\ObjectStore\ObjectStoreStorage;
2526
use OC\Files\Storage\Wrapper\Encryption;
2627
use OC\Files\Storage\Wrapper\Jail;
2728
use OCA\Files_Trashbin\Expiration;
@@ -299,9 +300,11 @@ private function moveFromEncryptedStorage(IStorage $sourceStorage, IStorage $tar
299300
$sourceStorage = $sourceStorage->getWrapperStorage();
300301
}
301302

303+
/** @psalm-suppress TooManyArguments */
302304
$result = $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
303305
if ($result) {
304-
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
306+
// hacky workaround to make sure we don't rely on a newer minor version
307+
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class) && is_callable([$sourceStorage, 'setPreserveCacheOnDelete'])) {
305308
/** @var ObjectStoreStorage $sourceStorage */
306309
$sourceStorage->setPreserveCacheOnDelete(true);
307310
}
@@ -312,7 +315,7 @@ private function moveFromEncryptedStorage(IStorage $sourceStorage, IStorage $tar
312315
$result = $sourceStorage->unlink($sourceInternalPath);
313316
}
314317
} finally {
315-
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
318+
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class) && is_callable([$sourceStorage, 'setPreserveCacheOnDelete'])) {
316319
/** @var ObjectStoreStorage $sourceStorage */
317320
$sourceStorage->setPreserveCacheOnDelete(false);
318321
}
@@ -345,6 +348,7 @@ private function getNodeForTrashItem(IUser $user, ITrashItem $trashItem): ?Node
345348
$folders = $this->folderManager->getFoldersForUser($user);
346349
foreach ($folders as $groupFolder) {
347350
if ($groupFolder['folder_id'] === $folderId) {
351+
/** @var Folder $trashRoot */
348352
$trashRoot = $this->rootFolder->get('/' . $user->getUID() . '/files_trashbin/groupfolders/' . $folderId);
349353
try {
350354
$node = $trashRoot->get($path);
@@ -411,6 +415,8 @@ private function getTrashForFolders(IUser $user, array $folders): array {
411415
// ensure the trash folder exists
412416
$this->getTrashFolder($folderId);
413417

418+
419+
/** @var Folder $trashFolder */
414420
$trashFolder = $this->rootFolder->get('/' . $user->getUID() . '/files_trashbin/groupfolders/' . $folderId);
415421
$content = $trashFolder->getDirectoryListing();
416422
$this->aclManagerFactory->getACLManager($user)->preloadRulesForFolder($trashFolder->getPath());

tests/stub.phpstub

+10-1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ namespace OCA\Files_Trashbin {
279279
*/
280280
public function isExpired($timestamp, $quotaExceeded = false) {}
281281
}
282+
283+
class Storage extends \OC\Files\Storage\Wrapper\Wrapper {
284+
}
282285
}
283286

284287

@@ -1500,7 +1503,7 @@ namespace OC\Files\Storage\Wrapper{
15001503
* @param string $targetInternalPath
15011504
* @return bool
15021505
*/
1503-
public function copyFromStorage(\OCP\Files\Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath)
1506+
public function copyFromStorage(\OCP\Files\Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false)
15041507
{
15051508
}
15061509
/**
@@ -1572,6 +1575,8 @@ namespace OC\Files\Storage\Wrapper{
15721575
class PermissionsMask extends Wrapper {
15731576
public function getQuota() {}
15741577
}
1578+
class Encryption extends \OC\Files\Storage\Wrapper\Wrapper {
1579+
}
15751580
}
15761581

15771582
namespace OC\Files\ObjectStore {
@@ -1667,3 +1672,7 @@ namespace OCA\DAV\Connector\Sabre\Exception {
16671672
public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) {}
16681673
}
16691674
}
1675+
1676+
namespace OC\Encryption\Exceptions {
1677+
class DecryptionFailedException extends \Exception {}
1678+
}

0 commit comments

Comments
 (0)