From 299520b32249881a2e459f9812c55dfc79f6d746 Mon Sep 17 00:00:00 2001 From: Frederik Kammer Date: Tue, 22 Mar 2016 16:49:14 +0100 Subject: [PATCH 1/3] Add config value for cache gc ttl --- config/config.sample.php | 8 ++++++++ lib/private/Cache/File.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config/config.sample.php b/config/config.sample.php index 2a368965fba..6ea7ea6fc1a 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -969,6 +969,14 @@ $CONFIG = array( */ 'cache_path' => '', +/** + * TTL of files located in the cache folder before they're removed by + * garbage collection (in seconds). Increase this value if users have + * issues uploading very large files via the ownCloud Client as upload isn't + * completed within one day. + */ +'cache_folder_gc_ttl' => 86400, // 60*60*24 = 1 day + /** * Using Object Store with ownCloud */ diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index 38f88959bd7..f2992a614e4 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -111,7 +111,7 @@ class File implements ICache { $keyPart = $key . '.' . $uniqueId . '.part'; if ($storage and $storage->file_put_contents($keyPart, $value)) { if ($ttl === 0) { - $ttl = 86400; // 60*60*24 + $ttl = \OC::$server->getConfig()->getSystemValue('cache_folder_gc_ttl', 86400); } $result = $storage->touch($keyPart, time() + $ttl); $result &= $storage->rename($keyPart, $key); From c9b26d065b567fa3a62a5ecfcfebb8fb275e9f1c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 24 May 2016 14:58:27 +0200 Subject: [PATCH 2/3] Move cache chunk TTL value to FileChunking class This makes it less generic and only used for actual file chunking --- lib/private/Cache/File.php | 2 +- lib/private/legacy/filechunking.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index f2992a614e4..38f88959bd7 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -111,7 +111,7 @@ class File implements ICache { $keyPart = $key . '.' . $uniqueId . '.part'; if ($storage and $storage->file_put_contents($keyPart, $value)) { if ($ttl === 0) { - $ttl = \OC::$server->getConfig()->getSystemValue('cache_folder_gc_ttl', 86400); + $ttl = 86400; // 60*60*24 } $result = $storage->touch($keyPart, time() + $ttl); $result &= $storage->rename($keyPart, $key); diff --git a/lib/private/legacy/filechunking.php b/lib/private/legacy/filechunking.php index f2cef275458..f58497a3c98 100644 --- a/lib/private/legacy/filechunking.php +++ b/lib/private/legacy/filechunking.php @@ -31,6 +31,13 @@ class OC_FileChunking { protected $info; protected $cache; + /** + * TTL of chunks + * + * @var int + */ + protected $ttl; + static public function decodeName($name) { preg_match('/(?P.*)-chunking-(?P\d+)-(?P\d+)-(?P\d+)/', $name, $matches); return $matches; @@ -41,6 +48,7 @@ class OC_FileChunking { */ public function __construct($info) { $this->info = $info; + $this->ttl = \OC::$server->getConfig()->getSystemValue('cache_folder_gc_ttl', 86400); } public function getPrefix() { @@ -67,7 +75,7 @@ class OC_FileChunking { public function store($index, $data) { $cache = $this->getCache(); $name = $this->getPrefix().$index; - $cache->set($name, $data); + $cache->set($name, $data, $this->ttl); return $cache->size($name); } From 51b0036d8f714e3693be744784f65c34dee64afa Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 24 May 2016 15:18:56 +0200 Subject: [PATCH 3/3] Changed labels of chunk TTL to mention chunks --- config/config.sample.php | 4 ++-- lib/private/legacy/filechunking.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index 6ea7ea6fc1a..1432ead7aa9 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -970,12 +970,12 @@ $CONFIG = array( 'cache_path' => '', /** - * TTL of files located in the cache folder before they're removed by + * TTL of chunks located in the cache folder before they're removed by * garbage collection (in seconds). Increase this value if users have * issues uploading very large files via the ownCloud Client as upload isn't * completed within one day. */ -'cache_folder_gc_ttl' => 86400, // 60*60*24 = 1 day +'cache_chunk_gc_ttl' => 86400, // 60*60*24 = 1 day /** * Using Object Store with ownCloud diff --git a/lib/private/legacy/filechunking.php b/lib/private/legacy/filechunking.php index f58497a3c98..9b8a5a6f766 100644 --- a/lib/private/legacy/filechunking.php +++ b/lib/private/legacy/filechunking.php @@ -48,7 +48,7 @@ class OC_FileChunking { */ public function __construct($info) { $this->info = $info; - $this->ttl = \OC::$server->getConfig()->getSystemValue('cache_folder_gc_ttl', 86400); + $this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400); } public function getPrefix() {