mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
fix(gc): Implement cache_chunk_gc_ttl
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
parent
ac3d09d817
commit
df018cf994
2 changed files with 8 additions and 7 deletions
|
|
@ -16,6 +16,8 @@ use OCP\Files\File;
|
|||
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 @@ class UploadCleanup extends TimedJob {
|
|||
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 @@ class UploadCleanup extends TimedJob {
|
|||
|
||||
/** @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) {
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ class File implements ICache {
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue