aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-09-30 13:21:07 +0200
committerdoktornotor <notordoktor@gmail.com>2015-09-30 13:21:07 +0200
commitb85616219c38868cae9840cf701d30476adc3384 (patch)
treee038e8db513fa82eaa9a83e0fab4a124636a3d52
parent614f420ec26939a0dec92997052a6bdebad52201 (diff)
downloadpfsense-packages-b85616219c38868cae9840cf701d30476adc3384.tar.gz
pfsense-packages-b85616219c38868cae9840cf701d30476adc3384.tar.bz2
pfsense-packages-b85616219c38868cae9840cf701d30476adc3384.zip
If disk cache gets disabled, delete the cachedir if it exists
-rwxr-xr-xconfig/squid3/34/squid.inc15
1 files changed, 14 insertions, 1 deletions
diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc
index 7d2b08b7..aa81a6c9 100755
--- a/config/squid3/34/squid.inc
+++ b/config/squid3/34/squid.inc
@@ -138,10 +138,23 @@ function squid_dash_z($cache_action = 'none') {
}
// If the cache system is null, there is no need to initialize the (irrelevant) cache dir.
+ // If it already exists, delete it.
if ($cachesettings['harddisk_cache_system'] == "null") {
+ if (is_dir($cachedir)) {
+ log_error("Deleting Squid cache dir {$cachedir} since 'Hard Disk Cache System' is set to null.");
+ // cannot nuke disk cache while Squid is running
+ squid_stop_monitor();
+ if (is_service_running('squid')) {
+ stop_service("squid");
+ }
+ rename($cachedir, "{$cachedir}.old");
+ mwexec_bg("/bin/rm -rf {$cachedir}.old");
+ squid_restart_services();
+ }
return;
}
- // Re-create the cachedir if clean is forced by cronjob/manually, or
+
+ // Re-create the cachedir if clean is forced by cronjob/manually,
// or if the cachedir changed, or level1_subdirs don't exist or the number of level1_subdirs changed
if ($cache_action == "clean" || ((!is_dir($cachedir)) || (!is_dir($cachedir . '/00'))) || ($numdirs !== $currentdirs)) {
// cannot nuke disk cache while Squid is running