Skip to content

Commit 9294ddf

Browse files
authored
Merge pull request #59831 from nextcloud/work/carl/files-applications-cleanup
refactor: Cleanup files app bootstrap
2 parents bf35fe8 + 5de4784 commit 9294ddf

9 files changed

Lines changed: 35 additions & 67 deletions

File tree

apps/files/composer/composer/autoload_classmap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php',
1818
'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => $baseDir . '/../lib/Activity/Settings/FileFavoriteChanged.php',
1919
'OCA\\Files\\AdvancedCapabilities' => $baseDir . '/../lib/AdvancedCapabilities.php',
20-
'OCA\\Files\\App' => $baseDir . '/../lib/App.php',
2120
'OCA\\Files\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
2221
'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => $baseDir . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php',
2322
'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir . '/../lib/BackgroundJob/CleanupFileLocks.php',

apps/files/composer/composer/autoload_static.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class ComposerStaticInitFiles
3232
'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php',
3333
'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileFavoriteChanged.php',
3434
'OCA\\Files\\AdvancedCapabilities' => __DIR__ . '/..' . '/../lib/AdvancedCapabilities.php',
35-
'OCA\\Files\\App' => __DIR__ . '/..' . '/../lib/App.php',
3635
'OCA\\Files\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
3736
'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php',
3837
'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupFileLocks.php',

apps/files/lib/App.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

apps/files/lib/AppInfo/Application.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace OCA\Files\AppInfo;
1111

12-
use Closure;
1312
use OCA\Files\AdvancedCapabilities;
1413
use OCA\Files\Capabilities;
1514
use OCA\Files\Collaboration\Resources\Listener;
@@ -41,8 +40,10 @@
4140
use OCP\Files\Events\Node\NodeCopiedEvent;
4241
use OCP\Files\Events\NodeAddedToFavorite;
4342
use OCP\Files\Events\NodeRemovedFromFavorite;
43+
use OCP\Share\Events\ShareCreatedEvent;
44+
use OCP\Share\Events\ShareDeletedEvent;
45+
use OCP\Share\Events\ShareDeletedFromSelfEvent;
4446
use OCP\User\Events\UserFirstTimeLoggedInEvent;
45-
use OCP\Util;
4647

4748
class Application extends App implements IBootstrap {
4849
public const APP_ID = 'files';
@@ -72,6 +73,10 @@ public function register(IRegistrationContext $context): void {
7273
$context->registerEventListener(NodeRemovedFromFavorite::class, NodeRemovedFromFavoriteListener::class);
7374
$context->registerEventListener(UserFirstTimeLoggedInEvent::class, UserFirstTimeLoggedInListener::class);
7475

76+
$context->registerEventListener(ShareCreatedEvent::class, Listener::class);
77+
$context->registerEventListener(ShareDeletedEvent::class, Listener::class);
78+
$context->registerEventListener(ShareDeletedFromSelfEvent::class, Listener::class);
79+
7580
$context->registerSearchProvider(FilesSearchProvider::class);
7681

7782
$context->registerNotifierService(Notifier::class);
@@ -83,16 +88,10 @@ public function register(IRegistrationContext $context): void {
8388

8489
#[\Override]
8590
public function boot(IBootContext $context): void {
86-
$context->injectFn(Closure::fromCallable([$this, 'registerCollaboration']));
87-
$context->injectFn([Listener::class, 'register']);
88-
$this->registerHooks();
91+
$context->injectFn(\Closure::fromCallable($this->registerCollaboration(...)));
8992
}
9093

9194
private function registerCollaboration(IProviderManager $providerManager): void {
9295
$providerManager->registerResourceProvider(ResourceProvider::class);
9396
}
94-
95-
private function registerHooks(): void {
96-
Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
97-
}
9897
}

apps/files/lib/BackgroundJob/ScanFiles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function runScanner(string $user): void {
5656
} catch (\Exception $e) {
5757
$this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'files']);
5858
}
59-
\OC_Util::tearDownFS();
59+
$this->setupManager->tearDown();
6060
}
6161

6262
/**
@@ -127,7 +127,7 @@ private function getAllMountedStorages(): array {
127127
* @throws \Exception
128128
*/
129129
#[\Override]
130-
protected function run($argument) {
130+
protected function run($argument): void {
131131
if ($this->config->getSystemValueBool('files_no_background_scan', false)) {
132132
return;
133133
}

apps/files/lib/Collaboration/Resources/Listener.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,31 @@
1010
namespace OCA\Files\Collaboration\Resources;
1111

1212
use OCP\Collaboration\Resources\IManager;
13-
use OCP\EventDispatcher\IEventDispatcher;
14-
use OCP\Server;
13+
use OCP\EventDispatcher\Event;
14+
use OCP\EventDispatcher\IEventListener;
1515
use OCP\Share\Events\ShareCreatedEvent;
1616
use OCP\Share\Events\ShareDeletedEvent;
1717
use OCP\Share\Events\ShareDeletedFromSelfEvent;
18+
use Override;
1819

19-
class Listener {
20-
public static function register(IEventDispatcher $dispatcher): void {
21-
$dispatcher->addListener(ShareCreatedEvent::class, [self::class, 'shareModification']);
22-
$dispatcher->addListener(ShareDeletedEvent::class, [self::class, 'shareModification']);
23-
$dispatcher->addListener(ShareDeletedFromSelfEvent::class, [self::class, 'shareModification']);
20+
/**
21+
* @template-implements IEventListener<ShareCreatedEvent|ShareDeletedEvent|ShareDeletedFromSelfEvent>
22+
*/
23+
class Listener implements IEventListener {
24+
public function __construct(
25+
protected readonly IManager $resourceManager,
26+
protected readonly ResourceProvider $resourceProvider,
27+
) {
2428
}
2529

26-
public static function shareModification(): void {
27-
/** @var IManager $resourceManager */
28-
$resourceManager = Server::get(IManager::class);
29-
/** @var ResourceProvider $resourceProvider */
30-
$resourceProvider = Server::get(ResourceProvider::class);
30+
#[Override]
31+
public function handle(Event $event): void {
32+
if ($event instanceof ShareDeletedFromSelfEvent || $event instanceof ShareDeletedEvent || $event instanceof ShareCreatedEvent) {
33+
$this->shareModification();
34+
}
35+
}
3136

32-
$resourceManager->invalidateAccessCacheForProvider($resourceProvider);
37+
public function shareModification(): void {
38+
$this->resourceManager->invalidateAccessCacheForProvider($this->resourceProvider);
3339
}
3440
}

apps/files_sharing/lib/Listener/LoadAdditionalListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function handle(Event $event): void {
3030
Util::addStyle(Application::APP_ID, 'icons');
3131

3232
$shareManager = Server::get(IManager::class);
33-
if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) {
33+
if ($shareManager->shareApiEnabled()) {
3434
Util::addInitScript(Application::APP_ID, 'init');
3535
}
3636
}

build/psalm-baseline.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,19 +1442,6 @@
14421442
<code><![CDATA[$this->fileIsEncrypted]]></code>
14431443
</TypeDoesNotContainType>
14441444
</file>
1445-
<file src="apps/files/lib/AppInfo/Application.php">
1446-
<DeprecatedMethod>
1447-
<code><![CDATA[Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig')]]></code>
1448-
</DeprecatedMethod>
1449-
</file>
1450-
<file src="apps/files/lib/BackgroundJob/ScanFiles.php">
1451-
<DeprecatedClass>
1452-
<code><![CDATA[\OC_Util::tearDownFS()]]></code>
1453-
</DeprecatedClass>
1454-
<DeprecatedMethod>
1455-
<code><![CDATA[\OC_Util::tearDownFS()]]></code>
1456-
</DeprecatedMethod>
1457-
</file>
14581445
<file src="apps/files/lib/Command/Object/Multi/Users.php">
14591446
<DeprecatedMethod>
14601447
<code><![CDATA[getUsersForUserValue]]></code>

lib/private/Template/JSConfigHelper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OC\CapabilitiesManager;
1414
use OC\Core\AppInfo\ConfigLexicon;
1515
use OC\Files\FilenameValidator;
16+
use OCA\Files\Service\ChunkedUploadConfig;
1617
use OCA\Provisioning_API\Controller\AUserDataOCSController;
1718
use OCP\App\AppPathNotFoundException;
1819
use OCP\App\IAppManager;
@@ -257,7 +258,10 @@ public function getConfig(): string {
257258
'defaultRemoteExpireDateEnabled' => $defaultRemoteExpireDateEnabled,
258259
'defaultRemoteExpireDate' => $defaultRemoteExpireDate,
259260
'defaultRemoteExpireDateEnforced' => $defaultRemoteExpireDateEnforced,
260-
]
261+
],
262+
'files' => [
263+
'max_chunk_size' => ChunkedUploadConfig::getMaxChunkSize(),
264+
],
261265
]),
262266
'_theme' => json_encode([
263267
'entity' => $this->defaults->getEntity(),
@@ -288,9 +292,6 @@ public function getConfig(): string {
288292
$this->initialStateService->provideInitialState('core', 'config', $config);
289293
$this->initialStateService->provideInitialState('core', 'capabilities', $capabilities);
290294

291-
// Allow hooks to modify the output values
292-
\OC_Hook::emit('\OCP\Config', 'js', ['array' => &$array]);
293-
294295
$result = '';
295296

296297
// Echo it

0 commit comments

Comments
 (0)