diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Cache/File.php | 12 | ||||
-rw-r--r-- | lib/private/Repair/NC32/AddFileCacheGcBackgroundJob.php | 29 |
2 files changed, 36 insertions, 5 deletions
diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index 99b14e92787..e8c436636ab 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -28,12 +28,14 @@ class File implements ICache { * @throws \OC\ForbiddenException * @throws \OC\User\NoUserException */ - protected function getStorage() { + protected function getStorage(?IUser $user = null): Folder { if ($this->storage !== null) { return $this->storage; } - $session = Server::get(IUserSession::class); - $user = $session->getUser(); + if (!$user) { + $session = Server::get(IUserSession::class); + $user = $session->getUser(); + } $rootFolder = Server::get(IRootFolder::class); if ($user) { $userId = $user->getUID(); @@ -156,8 +158,8 @@ class File implements ICache { * Runs GC * @throws \OC\ForbiddenException */ - public function gc() { - $storage = $this->getStorage(); + public function gc(?IUser $user = null) { + $storage = $this->getStorage($user); // extra hour safety, in case of stray part chunks that take longer to write, // because touch() is only called after the chunk was finished diff --git a/lib/private/Repair/NC32/AddFileCacheGcBackgroundJob.php b/lib/private/Repair/NC32/AddFileCacheGcBackgroundJob.php new file mode 100644 index 00000000000..b6b0af1bf32 --- /dev/null +++ b/lib/private/Repair/NC32/AddFileCacheGcBackgroundJob.php @@ -0,0 +1,29 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OC\Repair\NC32; + +use OC\Core\BackgroundJobs\FileCacheGcJob; +use OCP\BackgroundJob\IJobList; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class AddFileCacheGcBackgroundJob implements IRepairStep { + public function __construct( + private readonly IJobList $jobList, + ) { + } + + public function getName(): string { + return 'Add background job to cleanup file cache'; + } + + public function run(IOutput $output) { + $this->jobList->add(FileCacheGcJob::class); + } +} |