summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boost.admin.inc6
-rw-r--r--boost.module39
2 files changed, 26 insertions, 19 deletions
diff --git a/boost.admin.inc b/boost.admin.inc
index 0cbc93b..9a60b0a 100644
--- a/boost.admin.inc
+++ b/boost.admin.inc
@@ -241,6 +241,12 @@ function boost_admin_boost_performace_page() {
'#default_value' => BOOST_FLUSH_DIR,
'#description' => t('Disable this if you have to set settings for each dir/subdir, due to the way your server opperates (permissions, etc...).'),
);
+ $form['advanced']['boost_overwrite_file'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Overwrite the cached file if it already exits'),
+ '#default_value' => BOOST_OVERWRITE_FILE,
+ '#description' => t('This is useful if crawling a site before it goes live.'),
+ );
$form['advanced']['boost_halt_on_errors'] = array(
'#type' => 'checkbox',
'#title' => t('Do not cache if error on page'),
diff --git a/boost.module b/boost.module
index ca24261..bf7a91d 100644
--- a/boost.module
+++ b/boost.module
@@ -39,6 +39,7 @@ define('BOOST_CACHE_CSS', variable_get('boost_cache_css', FALSE));
define('BOOST_CACHE_JS', variable_get('boost_cache_js', FALSE));
define('BOOST_PERMISSIONS_FILE', variable_get('boost_permissions_file', ''));
define('BOOST_PERMISSIONS_DIR', variable_get('boost_permissions_dir', ''));
+define('BOOST_OVERWRITE_FILE', variable_get('boost_overwrite_file', FALSE));
// This cookie is set for all authenticated users, so that they can be
// excluded from caching (or in the future get a user-specific cached page):
@@ -920,14 +921,17 @@ function boost_cache_set($path, $data = '', $extension = BOOST_FILE_EXTENSION) {
db_set_active();
// Create or update the static files as needed
- if (($filename = boost_file_path($path, TRUE, $extension))) {
+ if (($filename = boost_file_path($path, TRUE, $extension)) && (BOOST_OVERWRITE_FILE || !file_exists($filename) || boost_db_is_expired($filename))) {
boost_cache_write($filename, $data);
if (BOOST_GZIP) {
boost_cache_write(str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename) . '.gz', gzencode($data, 9));
}
boost_db_prep($filename);
+ return TRUE;
+ }
+ else {
+ return FALSE;
}
- return TRUE;
}
/**
@@ -1014,26 +1018,23 @@ function boost_cache_write($filename, $data = '') {
if (!_boost_mkdir_p(dirname($filename))) {
watchdog('boost', 'Unable to create directory: %dir<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%dir' => dirname($filename), '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
}
- if (!file_exists($filename) || boost_db_is_expired($filename)) {
- $tempfile = $filename . getmypid();
- if (@file_put_contents($tempfile, $data) === FALSE) {
- watchdog('boost', 'Unable to write temp file: %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%file' => $tempfile, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
- return FALSE;
+ $tempfile = $filename . getmypid();
+ if (@file_put_contents($tempfile, $data) === FALSE) {
+ watchdog('boost', 'Unable to write temp file: %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%file' => $tempfile, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
+ return FALSE;
+ }
+ else {
+ if (is_numeric(BOOST_PERMISSIONS_FILE)) {
+ @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
}
- else {
- if (is_numeric(BOOST_PERMISSIONS_FILE)) {
- @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
- }
- // put the temp file in its final location
- if (@rename($tempfile, $filename) === FALSE) {
- watchdog('boost', 'Unable to rename file: %temp to %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%temp' => $tempfile, '%file' => $filename, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
- @unlink($tempfile);
- return FALSE;
- }
+ // put the temp file in its final location
+ if (@rename($tempfile, $filename) === FALSE) {
+ //watchdog('boost', 'Unable to rename file: %temp to %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%temp' => $tempfile, '%file' => $filename, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
+ @unlink($tempfile);
+ return FALSE;
}
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
/**