From aaf0f2cc5ffdd8b2683985c0ac324b3f3e16a82e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 May 2024 15:37:00 +0200 Subject: [PATCH] fix: log when no trash item is found Signed-off-by: Robin Appelman --- lib/ACL/ACLManager.php | 4 ++++ lib/ACL/ACLManagerFactory.php | 3 +++ lib/AppInfo/Application.php | 1 + 3 files changed, 8 insertions(+) diff --git a/lib/ACL/ACLManager.php b/lib/ACL/ACLManager.php index 5f5a834d7..56c9d8d29 100644 --- a/lib/ACL/ACLManager.php +++ b/lib/ACL/ACLManager.php @@ -28,6 +28,7 @@ use OCP\Constants; use OCP\Files\IRootFolder; use OCP\IUser; +use Psr\Log\LoggerInterface; class ACLManager { private CappedMemoryCache $ruleCache; @@ -37,6 +38,7 @@ class ACLManager { public function __construct( private RuleManager $ruleManager, private TrashManager $trashManager, + private LoggerInterface $logger, private IUser $user, callable $rootFolderProvider, private ?int $rootStorageId = null, @@ -121,6 +123,8 @@ private function getRelevantPaths(string $path): array { if ($trashItemRow) { $path = dirname('__groupfolders/' . $groupFolderId . '/' . $trashItemRow['original_location']); continue; + } else { + $this->logger->warning("failed to find trash item for $rootTrashedItemName deleted at $rootTrashedItemDate in folder $groupFolderId", ['app' => 'groupfolders']); } } diff --git a/lib/ACL/ACLManagerFactory.php b/lib/ACL/ACLManagerFactory.php index 11ea7ddfb..f9ce57e77 100644 --- a/lib/ACL/ACLManagerFactory.php +++ b/lib/ACL/ACLManagerFactory.php @@ -26,6 +26,7 @@ use OCA\GroupFolders\Trash\TrashManager; use OCP\IConfig; use OCP\IUser; +use Psr\Log\LoggerInterface; class ACLManagerFactory { private $rootFolderProvider; @@ -34,6 +35,7 @@ public function __construct( private RuleManager $ruleManager, private TrashManager $trashManager, private IConfig $config, + private LoggerInterface $logger, callable $rootFolderProvider, ) { $this->rootFolderProvider = $rootFolderProvider; @@ -43,6 +45,7 @@ public function getACLManager(IUser $user, ?int $rootStorageId = null): ACLManag return new ACLManager( $this->ruleManager, $this->trashManager, + $this->logger, $user, $this->rootFolderProvider, $rootStorageId, diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7cf1222bd..fe1040695 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -227,6 +227,7 @@ public function register(IRegistrationContext $context): void { $c->get(RuleManager::class), $c->get(TrashManager::class), $c->get(IConfig::class), + $c->get(LoggerInterface::class), $rootFolderProvider ); });