From e0af5263fb8352da39555033bd9555ba773d358a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 17 May 2016 17:03:42 +0200 Subject: [PATCH] Allow chunk GC mtime tolerance for unfinished part chunks Whenever part chunks are written, every fwrite in the write loop will reset the mtime to the current mtime. Only at the end will the touch() operation set the mtime to now + ttl, in the future. However the GC code is expecting that every chunk with mtime < now are old and must be deleted. This causes the GC to sometimes delete part chunks in which the write loop is slow. To fix this, a tolerance value is added in the GC code to allow for more time before a part chunk gets deleted. --- lib/private/Cache/File.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index 989e05275b..38f88959bd 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -172,7 +172,9 @@ class File implements ICache { public function gc() { $storage = $this->getStorage(); if ($storage and $storage->is_dir('/')) { - $now = time(); + // 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; $dh = $storage->opendir('/'); if (!is_resource($dh)) { return null;