|
@@ 426-445 (lines=20) @@
|
| 423 |
|
* @param string $destination |
| 424 |
|
* @param array $config |
| 425 |
|
*/ |
| 426 |
|
function upload($source, $destination, array $config = []) |
| 427 |
|
{ |
| 428 |
|
$rsync = Deployer::get()->rsync; |
| 429 |
|
$host = Context::get()->getHost(); |
| 430 |
|
$source = parse($source); |
| 431 |
|
$destination = parse($destination); |
| 432 |
|
|
| 433 |
|
if ($host instanceof Localhost) { |
| 434 |
|
$rsync->call($host->getHostname(), $source, $destination, $config); |
| 435 |
|
} else { |
| 436 |
|
$sshArguments = $host->getSshArguments()->getCliArguments(); |
| 437 |
|
if (empty($sshArguments) === false) { |
| 438 |
|
if (!isset($config['options']) || !is_array($config['options'])) { |
| 439 |
|
$config['options'] = []; |
| 440 |
|
} |
| 441 |
|
$config['options'][] = "-e 'ssh $sshArguments'"; |
| 442 |
|
} |
| 443 |
|
$rsync->call($host->getHostname(), $source, "$host:$destination", $config); |
| 444 |
|
} |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
/** |
| 448 |
|
* Download file or directory from host |
|
@@ 454-473 (lines=20) @@
|
| 451 |
|
* @param string $source |
| 452 |
|
* @param array $config |
| 453 |
|
*/ |
| 454 |
|
function download($source, $destination, array $config = []) |
| 455 |
|
{ |
| 456 |
|
$rsync = Deployer::get()->rsync; |
| 457 |
|
$host = Context::get()->getHost(); |
| 458 |
|
$source = parse($source); |
| 459 |
|
$destination = parse($destination); |
| 460 |
|
|
| 461 |
|
if ($host instanceof Localhost) { |
| 462 |
|
$rsync->call($host->getHostname(), $source, $destination, $config); |
| 463 |
|
} else { |
| 464 |
|
$sshArguments = $host->getSshArguments()->getCliArguments(); |
| 465 |
|
if (empty($sshArguments) === false) { |
| 466 |
|
if (!isset($config['options']) || !is_array($config['options'])) { |
| 467 |
|
$config['options'] = []; |
| 468 |
|
} |
| 469 |
|
$config['options'][] = "-e 'ssh $sshArguments'"; |
| 470 |
|
} |
| 471 |
|
$rsync->call($host->getHostname(), "$host:$source", $destination, $config); |
| 472 |
|
} |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
/** |
| 476 |
|
* Writes a message to the output and adds a newline at the end. |