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);