aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Cache/File.php
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2025-05-20 13:00:16 +0200
committerprovokateurin <kate@provokateurin.de>2025-05-20 13:00:16 +0200
commitb991c0e21c4b96a7758950ba991dfbecb9471af9 (patch)
treeae889da66d682611ae9caa951d65aea00596d866 /lib/private/Cache/File.php
parent565d524cd4b95e24469f9d0c105cd72dddbdd757 (diff)
downloadnextcloud-server-perf/files/cache-garbage-collection-background-job.tar.gz
nextcloud-server-perf/files/cache-garbage-collection-background-job.zip
perf(files): Move cache garbage collection to a background jobperf/files/cache-garbage-collection-background-job
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'lib/private/Cache/File.php')
-rw-r--r--lib/private/Cache/File.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php
index ceddf472ebd..91c19d437e3 100644
--- a/lib/private/Cache/File.php
+++ b/lib/private/Cache/File.php
@@ -26,14 +26,20 @@ class File implements ICache {
* @throws \OC\ForbiddenException
* @throws \OC\User\NoUserException
*/
- protected function getStorage() {
+ protected function getStorage(?string $userId = null) {
if ($this->storage !== null) {
return $this->storage;
}
- $session = Server::get(IUserSession::class);
- if ($session->isLoggedIn()) {
+
+ if ($userId === null) {
+ $session = Server::get(IUserSession::class);
+ if ($session->isLoggedIn()) {
+ $userId = $session->getUser()->getUID();
+ }
+ }
+
+ if ($userId !== null) {
$rootView = new View();
- $userId = $session->getUser()->getUID();
Filesystem::initMountPoints($userId);
if (!$rootView->file_exists('/' . $userId . '/cache')) {
$rootView->mkdir('/' . $userId . '/cache');
@@ -154,8 +160,8 @@ class File implements ICache {
* Runs GC
* @throws \OC\ForbiddenException
*/
- public function gc() {
- $storage = $this->getStorage();
+ public function gc(?string $userId = null) {
+ $storage = $this->getStorage($userId);
if ($storage) {
// extra hour safety, in case of stray part chunks that take longer to write,
// because touch() is only called after the chunk was finished