mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
API CHANGE: Added RsyncMultiHostPublisher::set_excluded_folders(). (from r104673)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@112456 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5cf2f46e4a
commit
93cbe1098a
@ -15,6 +15,8 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
|||||||
*/
|
*/
|
||||||
protected static $targets = array();
|
protected static $targets = array();
|
||||||
|
|
||||||
|
protected static $excluded_folders = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the targets to publish to.
|
* Set the targets to publish to.
|
||||||
* If target is an scp-style remote path, no password is accepted - we assume key-based authentication to be set up on the application server
|
* If target is an scp-style remote path, no password is accepted - we assume key-based authentication to be set up on the application server
|
||||||
@ -26,6 +28,14 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
|||||||
self::$targets = $targets;
|
self::$targets = $targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify folders to exclude from the rsync
|
||||||
|
* For example, you could exclude assets.
|
||||||
|
*/
|
||||||
|
static function set_excluded_folders($folders) {
|
||||||
|
self::$excluded_folders = $folders;
|
||||||
|
}
|
||||||
|
|
||||||
function publishPages($urls) {
|
function publishPages($urls) {
|
||||||
parent::publishPages($urls);
|
parent::publishPages($urls);
|
||||||
$base = Director::baseFolder();
|
$base = Director::baseFolder();
|
||||||
@ -33,11 +43,16 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
|||||||
// Get variable that can turn off the rsync component of publication
|
// Get variable that can turn off the rsync component of publication
|
||||||
if(isset($_GET['norsync']) && $_GET['norsync']) return;
|
if(isset($_GET['norsync']) && $_GET['norsync']) return;
|
||||||
|
|
||||||
|
$extraArg = "";
|
||||||
|
if(self::$excluded_folders) foreach(self::$excluded_folders as $folder) {
|
||||||
|
$extraArg .= " --exclude " . escapeshellarg($folder);
|
||||||
|
}
|
||||||
|
|
||||||
foreach(self::$targets as $target) {
|
foreach(self::$targets as $target) {
|
||||||
// Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc
|
// Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc
|
||||||
$rsyncOutput = `cd $base; rsync -av -e ssh --exclude /.htaccess --exclude '*.php' --exclude '*.svn' --exclude '*~' --delete . $target`;
|
$rsyncOutput = `cd $base; rsync -av -e ssh --exclude /.htaccess --exclude /web.config --exclude '*.php' --exclude '*.svn' --exclude '*.git' --exclude '*~' $extraArg --delete . $target`;
|
||||||
// Then transfer "safe" PHP from the cache/ directory
|
// Then transfer "safe" PHP from the cache/ directory
|
||||||
$rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' --delete cache $target`;
|
$rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' $extraArg --delete cache $target`;
|
||||||
if(StaticPublisher::echo_progress()) echo $rsyncOutput;
|
if(StaticPublisher::echo_progress()) echo $rsyncOutput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user