From 616e85e97ba3f2513487adbb89cda3b5c9cec2fa Mon Sep 17 00:00:00 2001 From: Hoang Pham Date: Mon, 5 Jan 2026 17:26:19 +0700 Subject: [PATCH] fix(encryption): init filesystem before unshare hook Signed-off-by: Hoang Pham --- lib/private/Encryption/HookManager.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/private/Encryption/HookManager.php b/lib/private/Encryption/HookManager.php index 39e7edabb9561..cc05eabd94d9f 100644 --- a/lib/private/Encryption/HookManager.php +++ b/lib/private/Encryption/HookManager.php @@ -22,6 +22,21 @@ public static function postShared($params): void { public static function postUnshared($params): void { // In case the unsharing happens in a background job, we don't have // a session and we load instead the user from the UserManager + if (Filesystem::getView() === null) { + $uidOwner = $params['uidOwner'] ?? ''; + if (is_string($uidOwner) && $uidOwner !== '') { + $user = \OC::$server->getUserManager()->get($uidOwner); + if ($user !== null) { + $setupManager = \OC::$server->get(SetupManager::class); + if (!$setupManager->isSetupComplete($user)) { + $setupManager->setupForUser($user); + } + } + } + } + if (Filesystem::getView() === null) { + return; + } $path = Filesystem::getPath($params['fileSource']); $owner = Filesystem::getOwner($path); self::getUpdate($owner)->postUnshared($params);