summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-02-20 08:59:22 +0100
committerGitHub <noreply@github.com>2023-02-20 08:59:22 +0100
commitbba3a1ccf0b41ee212cfb43ceee2b20e66904654 (patch)
treebf3e14dccf4609e1d0d2ad2aba09340a31ce3348 /apps/files
parentad6eb808c7166c77bddaa51c154998063f3688cc (diff)
parent3bdf3322ec208152dc3393b0076f076b8e9aaff2 (diff)
downloadnextcloud-server-bba3a1ccf0b41ee212cfb43ceee2b20e66904654.tar.gz
nextcloud-server-bba3a1ccf0b41ee212cfb43ceee2b20e66904654.zip
Merge pull request #36589 from nextcloud/enh/perf-remove-icache
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/appinfo/info.xml9
-rw-r--r--apps/files/composer/composer/ClassLoader.php12
-rw-r--r--apps/files/composer/composer/autoload_classmap.php1
-rw-r--r--apps/files/composer/composer/autoload_static.php1
-rw-r--r--apps/files/composer/composer/installed.php4
-rw-r--r--apps/files/lib/BackgroundJob/FileChunkCleanupJob.php62
6 files changed, 79 insertions, 10 deletions
diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml
index 1d06259074b..e69af548d9a 100644
--- a/apps/files/appinfo/info.xml
+++ b/apps/files/appinfo/info.xml
@@ -5,7 +5,7 @@
<name>Files</name>
<summary>File Management</summary>
<description>File Management</description>
- <version>1.21.1</version>
+ <version>1.21.2</version>
<licence>agpl</licence>
<author>Robin Appelman</author>
<author>Vincent Petry</author>
@@ -22,11 +22,12 @@
</dependencies>
<background-jobs>
- <job>OCA\Files\BackgroundJob\ScanFiles</job>
- <job>OCA\Files\BackgroundJob\DeleteOrphanedItems</job>
- <job>OCA\Files\BackgroundJob\CleanupFileLocks</job>
<job>OCA\Files\BackgroundJob\CleanupDirectEditingTokens</job>
+ <job>OCA\Files\BackgroundJob\CleanupFileLocks</job>
<job>OCA\Files\BackgroundJob\DeleteExpiredOpenLocalEditor</job>
+ <job>OCA\Files\BackgroundJob\DeleteOrphanedItems</job>
+ <job>OCA\Files\BackgroundJob\FileChunkCleanupJob</job>
+ <job>OCA\Files\BackgroundJob\ScanFiles</job>
</background-jobs>
<commands>
diff --git a/apps/files/composer/composer/ClassLoader.php b/apps/files/composer/composer/ClassLoader.php
index fd56bd7d840..a72151c77c8 100644
--- a/apps/files/composer/composer/ClassLoader.php
+++ b/apps/files/composer/composer/ClassLoader.php
@@ -429,7 +429,8 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
- (self::$includeFile)($file);
+ $includeFile = self::$includeFile;
+ $includeFile($file);
return true;
}
@@ -560,7 +561,10 @@ class ClassLoader
return false;
}
- private static function initializeIncludeClosure(): void
+ /**
+ * @return void
+ */
+ private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
@@ -574,8 +578,8 @@ class ClassLoader
* @param string $file
* @return void
*/
- self::$includeFile = static function($file) {
+ self::$includeFile = \Closure::bind(static function($file) {
include $file;
- };
+ }, null, null);
}
}
diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php
index ef3480081e0..642e5a1d87e 100644
--- a/apps/files/composer/composer/autoload_classmap.php
+++ b/apps/files/composer/composer/autoload_classmap.php
@@ -22,6 +22,7 @@ return array(
'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir . '/../lib/BackgroundJob/CleanupFileLocks.php',
'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => $baseDir . '/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php',
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
+ 'OCA\\Files\\BackgroundJob\\FileChunkCleanupJob' => $baseDir . '/../lib/BackgroundJob/FileChunkCleanupJob.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\BackgroundJob\\TransferOwnership' => $baseDir . '/../lib/BackgroundJob/TransferOwnership.php',
'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php
index 4f7872e39df..7287614d345 100644
--- a/apps/files/composer/composer/autoload_static.php
+++ b/apps/files/composer/composer/autoload_static.php
@@ -37,6 +37,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupFileLocks.php',
'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php',
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
+ 'OCA\\Files\\BackgroundJob\\FileChunkCleanupJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/FileChunkCleanupJob.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__ . '/..' . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\BackgroundJob\\TransferOwnership' => __DIR__ . '/..' . '/../lib/BackgroundJob/TransferOwnership.php',
'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
diff --git a/apps/files/composer/composer/installed.php b/apps/files/composer/composer/installed.php
index a1f6a8636b4..a07f17770d4 100644
--- a/apps/files/composer/composer/installed.php
+++ b/apps/files/composer/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => 'd51429a47232bbf46a2be832ecfa711f102da802',
+ 'reference' => '3e452cfe8d80995d1657c617f887a9ee422e6ab1',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => 'd51429a47232bbf46a2be832ecfa711f102da802',
+ 'reference' => '3e452cfe8d80995d1657c617f887a9ee422e6ab1',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
diff --git a/apps/files/lib/BackgroundJob/FileChunkCleanupJob.php b/apps/files/lib/BackgroundJob/FileChunkCleanupJob.php
new file mode 100644
index 00000000000..1c1f6f3bc99
--- /dev/null
+++ b/apps/files/lib/BackgroundJob/FileChunkCleanupJob.php
@@ -0,0 +1,62 @@
+<?php
+declare(strict_types=1);
+
+/**
+ * @copyright 2023 Anna Larch <anna.larch@gmx.net>
+ *
+ * @author Anna Larch <anna.larch@gmx.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Files\BackgroundJob;
+
+use OC\Cache\File;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\Job;
+use OCP\BackgroundJob\TimedJob;
+use OCP\Files\IRootFolder;
+use OCP\IUser;
+use OCP\IUserManager;
+use Psr\Log\LoggerInterface;
+
+class FileChunkCleanupJob extends TimedJob {
+ private IUserManager $userManager;
+ private IRootFolder $rootFolder;
+ private LoggerInterface $logger;
+
+ public function __construct(IUserManager $userManager, IRootFolder $rootFolder, LoggerInterface $logger, ITimeFactory $timeFactory) {
+ parent::__construct($timeFactory);
+ $this->setInterval(3600*24);
+ $this->setTimeSensitivity(Job::TIME_INSENSITIVE);
+ $this->userManager = $userManager;
+ $this->rootFolder = $rootFolder;
+ $this->logger = $logger;
+ }
+
+ /**
+ * This job cleans up all backups except the latest 3 from the updaters backup directory
+ */
+ public function run($argument): void {
+ $this->userManager->callForSeenUsers(function (IUser $user): void {
+ $this->logger->debug('Running chunk cleanup job for user '. $user->getUID());
+ $fileCache = new File();
+ $fileCache->setUpStorage($user->getUID());
+ $fileCache->gc();
+ $this->logger->debug('Finished running chunk cleanup job for user '. $user->getUID());
+ });
+ }
+}