mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
API CHANGE: Added RsyncMultiHostPublisher::set_excluded_folders().
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@104673 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5fd8e78f31
commit
bafeaaea1c
@ -15,6 +15,8 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
||||
*/
|
||||
protected static $targets = array();
|
||||
|
||||
protected static $excluded_folders = array();
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -26,6 +28,14 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
||||
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) {
|
||||
parent::publishPages($urls);
|
||||
$base = Director::baseFolder();
|
||||
@ -33,11 +43,16 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
|
||||
// Get variable that can turn off the rsync component of publication
|
||||
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) {
|
||||
// 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
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user