mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 17:22:41 +01:00
ensure the directory exists before upload a file in native ssh
This commit is contained in:
parent
43c7ef9a84
commit
5c2fcfef5f
@ -13,6 +13,11 @@ use Symfony\Component\Process\Process;
|
||||
|
||||
class NativeSsh implements ServerInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $mkdirs = [];
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
@ -43,7 +48,6 @@ class NativeSsh implements ServerInterface
|
||||
$sshOptions = [
|
||||
'-A',
|
||||
'-q',
|
||||
'-r',
|
||||
'-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
];
|
||||
|
||||
@ -82,6 +86,13 @@ class NativeSsh implements ServerInterface
|
||||
$username = $serverConfig->getUser() ? $serverConfig->getUser() : null;
|
||||
$hostname = $serverConfig->getHost();
|
||||
|
||||
$dir = dirname($remote);
|
||||
|
||||
if (!in_array($dir, $this->mkdirs)) {
|
||||
$this->run('mkdir -p ' . escapeshellarg($dir));
|
||||
$this->mkdirs[] = $dir;
|
||||
}
|
||||
|
||||
return $this->scpCopy($local, (!empty($username) ? $username . '@' : '') . $hostname . ':' . $remote);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user