mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
feat(OCP): Expose setup manager to OCP
It's used by a lot of apps so expose just the two methods that are most of the time used, to prevent the apps to relly on private APIs. Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
parent
2437046e25
commit
0fe01de26c
5 changed files with 45 additions and 9 deletions
|
|
@ -477,6 +477,7 @@ return array(
|
|||
'OCP\\Files\\IMimeTypeDetector' => $baseDir . '/lib/public/Files/IMimeTypeDetector.php',
|
||||
'OCP\\Files\\IMimeTypeLoader' => $baseDir . '/lib/public/Files/IMimeTypeLoader.php',
|
||||
'OCP\\Files\\IRootFolder' => $baseDir . '/lib/public/Files/IRootFolder.php',
|
||||
'OCP\\Files\\ISetupManager' => $baseDir . '/lib/public/Files/ISetupManager.php',
|
||||
'OCP\\Files\\InvalidCharacterInPathException' => $baseDir . '/lib/public/Files/InvalidCharacterInPathException.php',
|
||||
'OCP\\Files\\InvalidContentException' => $baseDir . '/lib/public/Files/InvalidContentException.php',
|
||||
'OCP\\Files\\InvalidDirectoryException' => $baseDir . '/lib/public/Files/InvalidDirectoryException.php',
|
||||
|
|
|
|||
|
|
@ -518,6 +518,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OCP\\Files\\IMimeTypeDetector' => __DIR__ . '/../../..' . '/lib/public/Files/IMimeTypeDetector.php',
|
||||
'OCP\\Files\\IMimeTypeLoader' => __DIR__ . '/../../..' . '/lib/public/Files/IMimeTypeLoader.php',
|
||||
'OCP\\Files\\IRootFolder' => __DIR__ . '/../../..' . '/lib/public/Files/IRootFolder.php',
|
||||
'OCP\\Files\\ISetupManager' => __DIR__ . '/../../..' . '/lib/public/Files/ISetupManager.php',
|
||||
'OCP\\Files\\InvalidCharacterInPathException' => __DIR__ . '/../../..' . '/lib/public/Files/InvalidCharacterInPathException.php',
|
||||
'OCP\\Files\\InvalidContentException' => __DIR__ . '/../../..' . '/lib/public/Files/InvalidContentException.php',
|
||||
'OCP\\Files\\InvalidDirectoryException' => __DIR__ . '/../../..' . '/lib/public/Files/InvalidDirectoryException.php',
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OC\Files;
|
||||
|
||||
use OC\Files\Cache\FileAccess;
|
||||
|
|
@ -13,8 +14,6 @@ use OC\Files\Config\MountProviderCollection;
|
|||
use OC\Files\Mount\HomeMountPoint;
|
||||
use OC\Files\Mount\MountPoint;
|
||||
use OC\Files\Storage\Common;
|
||||
use OC\Files\Storage\Home;
|
||||
use OC\Files\Storage\Storage;
|
||||
use OC\Files\Storage\Wrapper\Availability;
|
||||
use OC\Files\Storage\Wrapper\Encoding;
|
||||
use OC\Files\Storage\Wrapper\PermissionsMask;
|
||||
|
|
@ -43,6 +42,7 @@ use OCP\Files\Events\BeforeFileSystemSetupEvent;
|
|||
use OCP\Files\Events\InvalidateMountCacheEvent;
|
||||
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
|
||||
use OCP\Files\Events\Node\FilesystemTornDownEvent;
|
||||
use OCP\Files\ISetupManager;
|
||||
use OCP\Files\Mount\IMountManager;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
|
@ -57,13 +57,14 @@ use OCP\IUserManager;
|
|||
use OCP\IUserSession;
|
||||
use OCP\Lockdown\ILockdownManager;
|
||||
use OCP\Share\Events\ShareCreatedEvent;
|
||||
use Override;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function dirname;
|
||||
use function in_array;
|
||||
|
||||
class SetupManager {
|
||||
class SetupManager implements ISetupManager {
|
||||
private bool $rootSetup = false;
|
||||
// List of users for which at least one mount is setup
|
||||
private array $setupUsers = [];
|
||||
|
|
@ -143,7 +144,7 @@ class SetupManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
private function setupBuiltinWrappers() {
|
||||
private function setupBuiltinWrappers(): void {
|
||||
if ($this->setupBuiltinWrappersDone) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -256,9 +257,7 @@ class SetupManager {
|
|||
$updatingProviders = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the full filesystem for the specified user
|
||||
*/
|
||||
#[Override]
|
||||
public function setupForUser(IUser $user): void {
|
||||
if ($this->isSetupComplete($user)) {
|
||||
return;
|
||||
|
|
@ -711,7 +710,8 @@ class SetupManager {
|
|||
$this->eventLogger->end('fs:setup:user:providers');
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
#[Override]
|
||||
public function tearDown(): void {
|
||||
$this->setupUsers = [];
|
||||
$this->setupUsersComplete = [];
|
||||
$this->setupUserMountProviders = [];
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
|
||||
|
||||
$this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
|
||||
$this->registerAlias(\OCP\Files\ISetupManager::class, \OC\Files\SetupManager::class);
|
||||
|
||||
$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
|
||||
$this->registerAlias(ITemplateManager::class, TemplateManager::class);
|
||||
|
|
|
|||
33
lib/public/Files/ISetupManager.php
Normal file
33
lib/public/Files/ISetupManager.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCP\Files;
|
||||
|
||||
use OCP\AppFramework\Attribute\Consumable;
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* The files setup manager allow to set up the file system for specific users and
|
||||
* also to tear it down when no longer needed.
|
||||
*
|
||||
* @since 34.0.0
|
||||
*/
|
||||
#[Consumable(since: '34.0.0')]
|
||||
interface ISetupManager {
|
||||
|
||||
/**
|
||||
* Set up the full filesystem for a specified user.
|
||||
*/
|
||||
public function setupForUser(IUser $user): void;
|
||||
|
||||
/**
|
||||
* Tear down all file systems to free some memory.
|
||||
*/
|
||||
public function tearDown(): void;
|
||||
}
|
||||
Loading…
Reference in a new issue