File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
apps/dav/lib/BackgroundJob Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 1616use OCP \Files \Folder ;
1717use OCP \Files \IRootFolder ;
1818use OCP \Files \NotFoundException ;
19+ use OCP \IConfig ;
20+ use OCP \Server ;
1921use Psr \Log \LoggerInterface ;
2022
2123class UploadCleanup extends TimedJob {
@@ -47,8 +49,9 @@ protected function run($argument) {
4749 return ;
4850 }
4951
50- // Remove if all files have an mtime of more than a day
51- $ time = $ this ->time ->getTime () - 60 * 60 * 24 ;
52+ // Remove if all files have an mtime of more than a day or configured TTL
53+ $ ttl = Server::get (IConfig::class)->getSystemValueInt ('cache_chunk_gc_ttl ' , 60 * 60 * 24 );
54+ $ time = $ this ->time ->getTime () - $ ttl ;
5255
5356 if (!($ uploadFolder instanceof Folder)) {
5457 $ this ->logger ->error ('Found a file inside the uploads folder. Uid: ' . $ uid . ' folder: ' . $ folder );
@@ -61,8 +64,6 @@ protected function run($argument) {
6164
6265 /** @var File[] $files */
6366 $ files = $ uploadFolder ->getDirectoryListing ();
64-
65- // The folder has to be more than a day old
6667 $ initial = $ uploadFolder ->getMTime () < $ time ;
6768
6869 $ expire = array_reduce ($ files , function (bool $ carry , File $ file ) use ($ time ) {
Original file line number Diff line number Diff line change @@ -157,9 +157,9 @@ public function clear($prefix = '') {
157157 public function gc () {
158158 $ storage = $ this ->getStorage ();
159159 if ($ storage ) {
160- // extra hour safety, in case of stray part chunks that take longer to write,
161- // because touch () is only called after the chunk was finished
162- $ now = time () - 3600 ;
160+ $ ttl = \ OC :: $ server -> getConfig ()-> getSystemValueInt ( ' cache_chunk_gc_ttl ' , 60 * 60 * 24 );
161+ $ now = time () - $ ttl ;
162+
163163 $ dh = $ storage ->opendir ('/ ' );
164164 if (!is_resource ($ dh )) {
165165 return null ;
You can’t perform that action at this time.
0 commit comments