mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
refactor(setup-manager): Use ISetupManager instead of SetupManager
Keep using the OC API in the mount manager and OC_Utils, but the rest is now using the public API. Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
parent
0fe01de26c
commit
ae73f7aaf5
24 changed files with 93 additions and 83 deletions
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(), '/');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
4
apps/files_sharing/lib/External/Manager.php
vendored
4
apps/files_sharing/lib/External/Manager.php
vendored
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +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;
|
||||
|
|
@ -119,6 +119,7 @@ class SetupManager implements ISetupManager {
|
|||
return in_array($user->getUID(), $this->setupUsers, true);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function isSetupComplete(IUser $user): bool {
|
||||
return in_array($user->getUID(), $this->setupUsersComplete, true);
|
||||
}
|
||||
|
|
@ -451,10 +452,7 @@ class SetupManager implements ISetupManager {
|
|||
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) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
|
@ -16,6 +16,10 @@ 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')]
|
||||
|
|
@ -23,6 +27,9 @@ interface ISetupManager {
|
|||
|
||||
/**
|
||||
* Set up the full filesystem for a specified user.
|
||||
*
|
||||
* @throws \OCP\HintException
|
||||
* @throws \OC\ServerNotAvailableException
|
||||
*/
|
||||
public function setupForUser(IUser $user): void;
|
||||
|
||||
|
|
@ -30,4 +37,18 @@ interface ISetupManager {
|
|||
* 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue