Merge pull request #57826 from nextcloud/carl/setupmanager

feat(OCP): Expose setup manager to OCP
This commit is contained in:
Carl Schwan 2026-01-28 21:39:15 +01:00 committed by GitHub
commit ef226e9ec6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 133 additions and 87 deletions

View file

@ -9,11 +9,11 @@ declare(strict_types=1);
namespace OCA\Encryption\Command;
use OC\Encryption\Util;
use OC\Files\SetupManager;
use OCA\Encryption\Crypto\Encryption;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IUser;
@ -34,7 +34,7 @@ class CleanOrphanedKeys extends Command {
protected QuestionHelper $questionHelper,
private IUserManager $userManager,
private Util $encryptionUtil,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private IRootFolder $rootFolder,
private LoggerInterface $logger,
) {

View file

@ -11,10 +11,10 @@ namespace OCA\Encryption\Command;
use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Files\FileInfo;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\KeyManager;
use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\Files\ISetupManager;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
@ -27,7 +27,7 @@ class DropLegacyFileKey extends Command {
public function __construct(
private readonly IUserManager $userManager,
private readonly KeyManager $keyManager,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
) {
parent::__construct();

View file

@ -8,12 +8,12 @@
namespace OCA\Encryption\Command;
use OC\Files\SetupManager;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OC\ServerNotAvailableException;
use OCA\Encryption\Util;
use OCP\Encryption\Exceptions\InvalidHeaderException;
use OCP\Files\ISetupManager;
use OCP\HintException;
use OCP\IConfig;
use OCP\IUser;
@ -34,7 +34,7 @@ class FixEncryptedVersion extends Command {
private readonly IUserManager $userManager,
private readonly Util $util,
private readonly View $view,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
) {
parent::__construct();
}

View file

@ -10,7 +10,6 @@ namespace OCA\Encryption\Command;
use OC\Encryption\Manager;
use OC\Encryption\Util;
use OC\Files\SetupManager;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCP\Encryption\IManager;
@ -19,6 +18,7 @@ use OCP\Files\Config\IUserMountCache;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\Node;
use OCP\IUser;
use OCP\IUserManager;
@ -38,7 +38,7 @@ class FixKeyLocation extends Command {
private readonly IUserMountCache $userMountCache,
private readonly Util $encryptionUtil,
private readonly IRootFolder $rootFolder,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
IManager $encryptionManager,
) {
$this->keyRootDirectory = rtrim($this->encryptionUtil->getKeyStorageRoot(), '/');

View file

@ -8,9 +8,9 @@ declare(strict_types=1);
*/
namespace OCA\Encryption\Command;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\Util;
use OCP\Files\ISetupManager;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
@ -27,7 +27,7 @@ class ScanLegacyFormat extends Command {
protected readonly IConfig $config,
protected readonly QuestionHelper $questionHelper,
private readonly IUserManager $userManager,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
) {
parent::__construct();

View file

@ -11,12 +11,12 @@ declare(strict_types=1);
namespace OCA\Encryption\Crypto;
use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\Files\FileInfo;
use OCP\Files\ISetupManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
@ -53,7 +53,7 @@ class EncryptAll {
protected readonly QuestionHelper $questionHelper,
protected readonly ISecureRandom $secureRandom,
protected readonly LoggerInterface $logger,
protected readonly SetupManager $setupManager,
protected readonly ISetupManager $setupManager,
) {
}

View file

@ -10,7 +10,6 @@ namespace OCA\Encryption\Listeners;
use OC\Core\Events\BeforePasswordResetEvent;
use OC\Core\Events\PasswordResetEvent;
use OC\Files\SetupManager;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Services\PassphraseService;
use OCA\Encryption\Session;
@ -18,9 +17,8 @@ use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\ISetupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
use OCP\User\Events\BeforePasswordUpdatedEvent;
use OCP\User\Events\PasswordUpdatedEvent;
@ -40,9 +38,7 @@ class UserEventsListener implements IEventListener {
private Setup $userSetup,
private Session $session,
private KeyManager $keyManager,
private IUserManager $userManager,
private IUserSession $userSession,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private PassphraseService $passphraseService,
private ILockdownManager $lockdownManager,
) {

View file

@ -10,11 +10,11 @@ declare(strict_types=1);
namespace OCA\Encryption\Tests\Command;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\Command\FixEncryptedVersion;
use OCA\Encryption\Util;
use OCP\Encryption\IManager;
use OCP\Files\ISetupManager;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\ITempManager;
@ -69,7 +69,7 @@ class FixEncryptedVersionTest extends TestCase {
Server::get(IUserManager::class),
$this->util,
new View('/'),
Server::get(SetupManager::class),
Server::get(ISetupManager::class),
);
$this->commandTester = new CommandTester($this->fixEncryptedVersion);

View file

@ -9,13 +9,13 @@ declare(strict_types=1);
*/
namespace OCA\Encryption\Tests\Crypto;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\Crypto\EncryptAll;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\Files\FileInfo;
use OCP\Files\ISetupManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
@ -50,7 +50,7 @@ class EncryptAllTest extends TestCase {
protected UserInterface&MockObject $userInterface;
protected ISecureRandom&MockObject $secureRandom;
protected LoggerInterface&MockObject $logger;
protected SetupManager&MockObject $setupManager;
protected ISetupManager&MockObject $setupManager;
protected IUser&MockObject $user1;
protected IUser&MockObject $user2;
@ -84,7 +84,7 @@ class EncryptAllTest extends TestCase {
$this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock();
$this->logger = $this->createMock(LoggerInterface::class);
$this->setupManager = $this->createMock(SetupManager::class);
$this->setupManager = $this->createMock(ISetupManager::class);
/**
* We need format method to return a string

View file

@ -10,16 +10,14 @@ namespace OCA\Encryption\Tests\Listeners;
use OC\Core\Events\BeforePasswordResetEvent;
use OC\Core\Events\PasswordResetEvent;
use OC\Files\SetupManager;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Listeners\UserEventsListener;
use OCA\Encryption\Services\PassphraseService;
use OCA\Encryption\Session;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\Files\ISetupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
use OCP\User\Events\BeforePasswordUpdatedEvent;
use OCP\User\Events\PasswordUpdatedEvent;
@ -32,14 +30,11 @@ use Test\TestCase;
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
class UserEventsListenersTest extends TestCase {
protected Util&MockObject $util;
protected Setup&MockObject $userSetup;
protected Session&MockObject $session;
protected KeyManager&MockObject $keyManager;
protected IUserManager&MockObject $userManager;
protected IUserSession&MockObject $userSession;
protected SetupManager&MockObject $setupManager;
protected ISetupManager&MockObject $setupManager;
protected ILockdownManager&MockObject $lockdownManager;
protected PassphraseService&MockObject $passphraseService;
@ -52,9 +47,7 @@ class UserEventsListenersTest extends TestCase {
$this->userSetup = $this->createMock(Setup::class);
$this->session = $this->createMock(Session::class);
$this->keyManager = $this->createMock(KeyManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->setupManager = $this->createMock(SetupManager::class);
$this->setupManager = $this->createMock(ISetupManager::class);
$this->lockdownManager = $this->createMock(ILockdownManager::class);
$this->passphraseService = $this->createMock(PassphraseService::class);
@ -63,8 +56,6 @@ class UserEventsListenersTest extends TestCase {
$this->userSetup,
$this->session,
$this->keyManager,
$this->userManager,
$this->userSession,
$this->setupManager,
$this->passphraseService,
$this->lockdownManager,

View file

@ -8,7 +8,6 @@ namespace OCA\FederatedFileSharing\OCM;
use OC\AppFramework\Http;
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Federation\TrustedServers;
@ -31,6 +30,7 @@ use OCP\Federation\ICloudFederationShare;
use OCP\Federation\ICloudIdManager;
use OCP\Federation\ISignedCloudFederationProvider;
use OCP\Files\IFilenameValidator;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\HintException;
use OCP\IConfig;
@ -68,7 +68,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
private readonly LoggerInterface $logger,
private readonly IFilenameValidator $filenameValidator,
private readonly IProviderFactory $shareProviderFactory,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
private readonly ExternalShareMapper $externalShareMapper,
) {
}

View file

@ -8,7 +8,6 @@ declare(strict_types=1);
*/
namespace OCA\Files\BackgroundJob;
use OC\Files\SetupManager;
use OCA\Files\AppInfo\Application;
use OCA\Files\Service\SettingsService;
use OCP\AppFramework\Services\IAppConfig;
@ -16,10 +15,10 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\QueuedJob;
use OCP\Config\IUserConfig;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IFilenameValidator;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IUser;
@ -43,7 +42,7 @@ class SanitizeFilenames extends QueuedJob {
private IAppConfig $appConfig,
private IUserConfig $userConfig,
private IRootFolder $rootFolder,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private IFilenameValidator $filenameValidator,
private LoggerInterface $logger,
) {

View file

@ -9,7 +9,6 @@
namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OC\User\NoUserException;
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
use OCA\Files_Sharing\Helper;
@ -21,6 +20,7 @@ use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\IStorageFactory;
@ -53,7 +53,7 @@ class Manager {
private IEventDispatcher $eventDispatcher,
private LoggerInterface $logger,
private IRootFolder $rootFolder,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private ICertificateManager $certificateManager,
private ExternalShareMapper $externalShareMapper,
) {

View file

@ -9,11 +9,11 @@ declare(strict_types=1);
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OC\Files\View;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\ISetupManager;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\IUser;
@ -30,7 +30,7 @@ class ShareTargetValidator {
public function __construct(
private readonly IManager $shareManager,
private readonly IEventDispatcher $eventDispatcher,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
private readonly IMountManager $mountManager,
) {
$this->folderExistsCache = new CappedMemoryCache();

View file

@ -9,7 +9,6 @@ namespace OCA\Files_Sharing\Tests;
use OC\Files\Cache\Cache;
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
@ -18,6 +17,7 @@ use OCA\Files_Sharing\SharedStorage;
use OCP\Constants;
use OCP\Files\Cache\IWatcher;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\Node;
use OCP\IUserManager;
use OCP\Server;
@ -412,7 +412,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(Filesystem::file_exists('/test.txt'));
@ -443,7 +443,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(Filesystem::file_exists('/foo'));
@ -471,7 +471,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
[$sourceStorage] = Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo');
@ -508,7 +508,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertEquals('foo', Filesystem::file_get_contents('/sub/foo.txt'));
@ -547,7 +547,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@ -582,7 +582,7 @@ class CacheTest extends TestCase {
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
Server::get(SetupManager::class)->tearDown();
Server::get(ISetupManager::class)->tearDown();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);

View file

@ -9,7 +9,6 @@ namespace OCA\Files_Sharing\Tests\External;
use OC\Federation\CloudIdManager;
use OC\Files\Mount\MountPoint;
use OC\Files\SetupManager;
use OC\Files\SetupManagerFactory;
use OC\Files\Storage\StorageFactory;
use OC\Files\Storage\Temporary;
@ -24,6 +23,7 @@ use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
@ -68,7 +68,7 @@ class ManagerTest extends TestCase {
protected ICloudFederationFactory&MockObject $cloudFederationFactory;
protected IGroupManager&MockObject $groupManager;
protected IUserManager&MockObject $userManager;
protected SetupManager&MockObject $setupManager;
protected ISetupManager&MockObject $setupManager;
protected ICertificateManager&MockObject $certificateManager;
private ExternalShareMapper $externalShareMapper;
@ -84,7 +84,7 @@ class ManagerTest extends TestCase {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->setupManager = $this->createMock(SetupManager::class);
$this->setupManager = $this->createMock(ISetupManager::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->rootFolder->method('getUserFolder')
->willReturnCallback(function (string $userId): Folder {

View file

@ -7,13 +7,13 @@
*/
namespace OCA\Files_Trashbin\BackgroundJob;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Trashbin;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\Files\ISetupManager;
use OCP\IAppConfig;
use OCP\IUser;
use OCP\IUserManager;
@ -32,7 +32,7 @@ class ExpireTrash extends TimedJob {
private IUserManager $userManager,
private Expiration $expiration,
private LoggerInterface $logger,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private ILockingProvider $lockingProvider,
ITimeFactory $time,
) {

View file

@ -9,12 +9,12 @@ declare(strict_types=1);
namespace OCA\Files_Trashbin\Tests\BackgroundJob;
use OC\Files\SetupManager;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\BackgroundJob\ExpireTrash;
use OCA\Files_Trashbin\Expiration;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Files\ISetupManager;
use OCP\IAppConfig;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
@ -29,7 +29,7 @@ class ExpireTrashTest extends TestCase {
private IJobList&MockObject $jobList;
private LoggerInterface&MockObject $logger;
private ITimeFactory&MockObject $time;
private SetupManager&MockObject $setupManager;
private ISetupManager&MockObject $setupManager;
private ILockingProvider&MockObject $lockingProvider;
protected function setUp(): void {
@ -40,7 +40,7 @@ class ExpireTrashTest extends TestCase {
$this->expiration = $this->createMock(Expiration::class);
$this->jobList = $this->createMock(IJobList::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->setupManager = $this->createMock(SetupManager::class);
$this->setupManager = $this->createMock(ISetupManager::class);
$this->lockingProvider = $this->createMock(ILockingProvider::class);
$this->time = $this->createMock(ITimeFactory::class);

View file

@ -9,8 +9,8 @@ declare(strict_types=1);
namespace OC\Core\Command\Background;
use OC\Core\Command\InterruptedException;
use OC\Files\SetupManager;
use OCP\BackgroundJob\IJobList;
use OCP\Files\ISetupManager;
use OCP\ITempManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputArgument;
@ -24,7 +24,7 @@ class JobWorker extends JobBase {
protected IJobList $jobList,
protected LoggerInterface $logger,
private ITempManager $tempManager,
private SetupManager $setupManager,
private ISetupManager $setupManager,
) {
parent::__construct($jobList, $logger);
}

View file

@ -7,7 +7,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OC\Files\SetupManager;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IUser;
@ -22,12 +22,12 @@ class Info extends Base {
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
protected SetupManager $setupManager,
protected ISetupManager $setupManager,
) {
parent::__construct();
}
protected function configure() {
protected function configure(): void {
$this
->setName('user:info')
->setDescription('show user info')

View file

@ -13,13 +13,13 @@ namespace OC\Core\Service;
use OC;
use OC\Authentication\LoginCredentials\Store;
use OC\Files\SetupManager;
use OC\Security\CSRF\TokenStorage\SessionStorage;
use OC\Session\CryptoWrapper;
use OC\Session\Memory;
use OC\User\Session;
use OCP\App\IAppManager;
use OCP\BackgroundJob\IJobList;
use OCP\Files\ISetupManager;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\ILogger;
@ -44,7 +44,7 @@ class CronService {
private readonly ITempManager $tempManager,
private readonly IAppConfig $appConfig,
private readonly IJobList $jobList,
private readonly SetupManager $setupManager,
private readonly ISetupManager $setupManager,
private readonly bool $isCLI,
) {
}

View file

@ -478,6 +478,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',

View file

@ -519,6 +519,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',

View file

@ -9,18 +9,22 @@ declare(strict_types=1);
namespace OC\Encryption;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
use OCP\Encryption\IFile;
use OCP\Encryption\IManager as IEncryptionManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Server;
use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\Events\ShareDeletedEvent;
use Psr\Log\LoggerInterface;
@ -31,7 +35,7 @@ class EncryptionEventListener implements IEventListener {
public function __construct(
private IUserSession $userSession,
private SetupManager $setupManager,
private ISetupManager $setupManager,
private Manager $encryptionManager,
private IUserManager $userManager,
) {
@ -55,10 +59,10 @@ class EncryptionEventListener implements IEventListener {
} elseif ($event instanceof ShareDeletedEvent) {
try {
// In case the unsharing happens in a background job, we don't have
// a session and we load instead the user from the UserManager
// a session, and we load instead the user from the UserManager
$owner = $this->userManager->get($event->getShare()->getShareOwner());
$this->getUpdate($owner)->postUnshared($event->getShare()->getNode());
} catch (NotFoundException $e) {
} catch (NotFoundException) {
/* The node was deleted already, nothing to update */
}
} elseif ($event instanceof NodeRestoredEvent) {
@ -81,11 +85,12 @@ class EncryptionEventListener implements IEventListener {
new Util(
new View(),
$this->userManager,
\OC::$server->getGroupManager(),
\OC::$server->getConfig()),
\OC::$server->getEncryptionManager(),
\OC::$server->get(IFile::class),
\OC::$server->get(LoggerInterface::class),
Server::get(IGroupManager::class),
Server::get(IConfig::class)
),
Server::get(IEncryptionManager::class),
Server::get(IFile::class),
Server::get(LoggerInterface::class),
);
}

View file

@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@ -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 = [];
@ -118,6 +119,7 @@ class SetupManager {
return in_array($user->getUID(), $this->setupUsers, true);
}
#[Override]
public function isSetupComplete(IUser $user): bool {
return in_array($user->getUID(), $this->setupUsersComplete, true);
}
@ -143,7 +145,7 @@ class SetupManager {
return false;
}
private function setupBuiltinWrappers() {
private function setupBuiltinWrappers(): void {
if ($this->setupBuiltinWrappersDone) {
return;
}
@ -256,9 +258,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;
@ -454,10 +454,7 @@ class SetupManager {
return $this->userManager->get($userId);
}
/**
* Set up the filesystem for the specified path, optionally including all
* children mounts.
*/
#[Override]
public function setupForPath(string $path, bool $includeChildren = false): void {
$user = $this->getUserForPath($path);
if (!$user) {
@ -724,7 +721,8 @@ class SetupManager {
$this->eventLogger->end('fs:setup:user:providers');
}
public function tearDown() {
#[Override]
public function tearDown(): void {
$this->setupUsers = [];
$this->setupUsersComplete = [];
$this->setupUserMountProviders = [];

View file

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

View file

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
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.
*
* This is mostly useful in backgroun jobs, where an operation need to be done for
* multiple users and their file system need to be setup and teared down between
* each user.
*
* @since 34.0.0
*/
#[Consumable(since: '34.0.0')]
interface ISetupManager {
/**
* Set up the full filesystem for a specified user.
*
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException
*/
public function setupForUser(IUser $user): void;
/**
* Tear down all file systems to free some memory.
*/
public function tearDown(): void;
/**
* Set up the filesystem for the specified path, optionally including all
* children mounts.
*
* @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException
*/
public function setupForPath(string $path, bool $includeChildren = false): void;
/**
* Get whether the file system is already setup for a specific user.
*/
public function isSetupComplete(IUser $user): bool;
}