MINOR added locking to static publisher to avoid two queues running at the same time. (from r87792)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@98164 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-02-04 04:41:20 +00:00
parent 7514bdcd6b
commit 0fc5b63270
2 changed files with 13 additions and 5 deletions

View File

@ -86,9 +86,11 @@ SideReportRecord.prototype = {
}, },
onclick : function(event) { onclick : function(event) {
Event.stop(event); if (!this.getAttribute('reloadCMS')) {
$('sitetree').loadingNode = $('sitetree').getTreeNodeByIdx( this.getID() ); Event.stop(event);
$('Form_EditForm').getPageFromServer(this.getID()); $('sitetree').loadingNode = $('sitetree').getTreeNodeByIdx( this.getID() );
$('Form_EditForm').getPageFromServer(this.getID());
}
}, },
getID : function() { getID : function() {
if(this.href.match(/\/([^\/]+)$/)) return parseInt(RegExp.$1); if(this.href.match(/\/([^\/]+)$/)) return parseInt(RegExp.$1);

View File

@ -44,6 +44,11 @@ class RebuildStaticCacheTask extends Controller {
echo "Rebuilding cache.\nNOTE: Please ensure that this page ends with 'Done!' - if not, then something may have gone wrong.\n\n"; echo "Rebuilding cache.\nNOTE: Please ensure that this page ends with 'Done!' - if not, then something may have gone wrong.\n\n";
$page = singleton('Page'); $page = singleton('Page');
$cacheBaseDir = $page->getDestDir();
if (file_exists($cacheBaseDir.'/lock') && !isset($_REQUEST['force'])) die("There already appears to be a publishing queue running. You can skip warning this by adding ?/&force to the URL.");
touch($cacheBaseDir.'/lock');
foreach($urls as $i => $url) { foreach($urls as $i => $url) {
if($url && !is_string($url)) { if($url && !is_string($url)) {
@ -68,8 +73,6 @@ class RebuildStaticCacheTask extends Controller {
if(!isset($_GET['urls']) && $start == 0 && file_exists("../cache")) { if(!isset($_GET['urls']) && $start == 0 && file_exists("../cache")) {
echo "Removing stale cache files... \n"; echo "Removing stale cache files... \n";
flush(); flush();
$cacheBaseDir = $page->getDestDir();
if (FilesystemPublisher::$domain_based_caching) { if (FilesystemPublisher::$domain_based_caching) {
// Glob each dir, then glob each one of those // Glob each dir, then glob each one of those
foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) { foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
@ -89,6 +92,9 @@ class RebuildStaticCacheTask extends Controller {
} }
echo "Rebuilding cache from " . sizeof($mappedUrls) . " urls...\n\n"; echo "Rebuilding cache from " . sizeof($mappedUrls) . " urls...\n\n";
$page->extend('publishPages', $mappedUrls); $page->extend('publishPages', $mappedUrls);
if (file_exists($cacheBaseDir.'/lock')) unlink($cacheBaseDir.'/lock');
echo "\n\n== Done! =="; echo "\n\n== Done! ==";
} }