diff --git a/apps/dav/lib/BackgroundJob/UploadCleanup.php b/apps/dav/lib/BackgroundJob/UploadCleanup.php index 230cde61578e1..a394b7356bdb8 100644 --- a/apps/dav/lib/BackgroundJob/UploadCleanup.php +++ b/apps/dav/lib/BackgroundJob/UploadCleanup.php @@ -16,6 +16,8 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; +use OCP\IConfig; +use OCP\Server; use Psr\Log\LoggerInterface; class UploadCleanup extends TimedJob { @@ -47,8 +49,9 @@ protected function run($argument) { return; } - // Remove if all files have an mtime of more than a day - $time = $this->time->getTime() - 60 * 60 * 24; + // Remove if all files have an mtime of more than a day or configured TTL + $ttl = Server::get(IConfig::class)->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24); + $time = $this->time->getTime() - $ttl; if (!($uploadFolder instanceof Folder)) { $this->logger->error('Found a file inside the uploads folder. Uid: ' . $uid . ' folder: ' . $folder); @@ -61,8 +64,6 @@ protected function run($argument) { /** @var File[] $files */ $files = $uploadFolder->getDirectoryListing(); - - // The folder has to be more than a day old $initial = $uploadFolder->getMTime() < $time; $expire = array_reduce($files, function (bool $carry, File $file) use ($time) { diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index ceddf472ebdc4..e5cd9c1dd300e 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -157,9 +157,9 @@ public function clear($prefix = '') { public function gc() { $storage = $this->getStorage(); 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 - $now = time() - 3600; + $ttl = \OC::$server->getConfig()->getSystemValueInt('cache_chunk_gc_ttl', 60 * 60 * 24); + $now = time() - $ttl; + $dh = $storage->opendir('/'); if (!is_resource($dh)) { return null;