composer update
This commit is contained in:
@@ -557,6 +557,10 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected function normalizePermissions($permissions)
|
||||
{
|
||||
if (is_numeric($permissions)) {
|
||||
return ((int) $permissions) & 0777;
|
||||
}
|
||||
|
||||
// remove the type identifier
|
||||
$permissions = substr($permissions, 1);
|
||||
|
||||
|
||||
+23
-21
@@ -6,9 +6,11 @@ use ErrorException;
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\ConnectionErrorException;
|
||||
use League\Flysystem\ConnectionRuntimeException;
|
||||
use League\Flysystem\InvalidRootException;
|
||||
use League\Flysystem\Util;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use RuntimeException;
|
||||
|
||||
class Ftp extends AbstractFtpAdapter
|
||||
{
|
||||
@@ -129,13 +131,13 @@ class Ftp extends AbstractFtpAdapter
|
||||
public function connect()
|
||||
{
|
||||
if ($this->ssl) {
|
||||
$this->connection = ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
$this->connection = @ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
} else {
|
||||
$this->connection = ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
$this->connection = @ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
|
||||
}
|
||||
|
||||
if ( ! $this->connection) {
|
||||
throw new RuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
|
||||
throw new ConnectionRuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
|
||||
}
|
||||
|
||||
$this->login();
|
||||
@@ -153,7 +155,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
if ($this->utf8) {
|
||||
$response = ftp_raw($this->connection, "OPTS UTF8 ON");
|
||||
if (substr($response[0], 0, 3) !== '200') {
|
||||
throw new RuntimeException(
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
@@ -163,7 +165,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
/**
|
||||
* Set the connections to passive mode.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function setConnectionPassiveMode()
|
||||
{
|
||||
@@ -172,7 +174,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
}
|
||||
|
||||
if ( ! ftp_pasv($this->connection, $this->passive)) {
|
||||
throw new RuntimeException(
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
|
||||
);
|
||||
}
|
||||
@@ -187,7 +189,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
$connection = $this->connection;
|
||||
|
||||
if ($root && ! ftp_chdir($connection, $root)) {
|
||||
throw new RuntimeException('Root is invalid or does not exist: ' . $this->getRoot());
|
||||
throw new InvalidRootException('Root is invalid or does not exist: ' . $this->getRoot());
|
||||
}
|
||||
|
||||
// Store absolute path for further reference.
|
||||
@@ -200,7 +202,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
/**
|
||||
* Login.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws ConnectionRuntimeException
|
||||
*/
|
||||
protected function login()
|
||||
{
|
||||
@@ -215,7 +217,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
|
||||
if ( ! $isLoggedIn) {
|
||||
$this->disconnect();
|
||||
throw new RuntimeException(
|
||||
throw new ConnectionRuntimeException(
|
||||
'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort(
|
||||
) . ', username: ' . $this->getUsername()
|
||||
);
|
||||
@@ -228,7 +230,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
public function disconnect()
|
||||
{
|
||||
if (is_resource($this->connection)) {
|
||||
ftp_close($this->connection);
|
||||
@ftp_close($this->connection);
|
||||
}
|
||||
|
||||
$this->connection = null;
|
||||
@@ -526,19 +528,12 @@ class Ftp extends AbstractFtpAdapter
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws ErrorException
|
||||
* @throws ConnectionErrorException
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
try {
|
||||
return is_resource($this->connection) && ftp_rawlist($this->connection, $this->getRoot()) !== false;
|
||||
} catch (ErrorException $e) {
|
||||
if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return is_resource($this->connection)
|
||||
&& $this->getRawExecResponseCode('NOOP') === 200;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,4 +564,11 @@ class Ftp extends AbstractFtpAdapter
|
||||
|
||||
return ftp_rawlist($connection, $options . ' ' . $path);
|
||||
}
|
||||
|
||||
private function getRawExecResponseCode($command)
|
||||
{
|
||||
$response = @ftp_raw($this->connection, trim($command));
|
||||
|
||||
return (int) preg_replace('/\D/', '', implode(' ', $response));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user