From d6eaa8eaf6f8108b0b4558229b04415e62586d2a Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 30 Aug 2013 04:41:59 -0400
Subject: [PATCH] Merge pull request #111 from dpc22/temp_dir_ttl
---
program/lib/Roundcube/rcube.php | 9 ++++++++-
config/defaults.inc.php | 4 ++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/config/defaults.inc.php b/config/defaults.inc.php
index 54d0b1d..5124552 100644
--- a/config/defaults.inc.php
+++ b/config/defaults.inc.php
@@ -257,6 +257,10 @@
// use this folder to store temp files (must be writeable for apache user)
$config['temp_dir'] = 'temp/';
+// expire files in temp_dir after 48 hours
+// possible units: s, m, h, d, w
+$config['temp_dir_ttl'] = '48h';
+
// enforce connections over https
// with this option enabled, all non-secure connections will be redirected.
// set the port for the ssl connection as value of this option if it differs from the default 443
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index af9c069..d9c3dd8 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -498,7 +498,14 @@
public function gc_temp()
{
$tmp = unslashify($this->config->get('temp_dir'));
- $expire = time() - 172800; // expire in 48 hours
+
+ // expire in 48 hours by default
+ $temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h');
+ $temp_dir_ttl = get_offset_sec($temp_dir_ttl);
+ if ($temp_dir_ttl < 6*3600)
+ $temp_dir_ttl = 6*3600; // 6 hours sensible lower bound.
+
+ $expire = time() - $temp_dir_ttl;
if ($tmp && ($dir = opendir($tmp))) {
while (($fname = readdir($dir)) !== false) {
--
Gitblit v1.9.1