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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ConnectionErrorException extends ErrorException implements FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class ConnectionRuntimeException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
class Exception extends \Exception
|
||||
class Exception extends \Exception implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
interface FilesystemException
|
||||
{
|
||||
}
|
||||
@@ -7,6 +7,6 @@ use LogicException;
|
||||
/**
|
||||
* Thrown when the MountManager cannot find a filesystem.
|
||||
*/
|
||||
class FilesystemNotFoundException extends LogicException
|
||||
class FilesystemNotFoundException extends LogicException implements FilesystemException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InvalidRootException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace League\Flysystem;
|
||||
use RuntimeException;
|
||||
use SplFileInfo;
|
||||
|
||||
class NotSupportedException extends RuntimeException
|
||||
class NotSupportedException extends RuntimeException implements FilesystemException
|
||||
{
|
||||
/**
|
||||
* Create a new exception for a link.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ namespace League\Flysystem;
|
||||
|
||||
use LogicException;
|
||||
|
||||
class RootViolationException extends LogicException
|
||||
class RootViolationException extends LogicException implements FilesystemException
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
Vendored
+5
-1
@@ -267,12 +267,16 @@ class Util
|
||||
*
|
||||
* @param resource $resource
|
||||
*
|
||||
* @return int stream size
|
||||
* @return int|null stream size
|
||||
*/
|
||||
public static function getStreamSize($resource)
|
||||
{
|
||||
$stat = fstat($resource);
|
||||
|
||||
if ( ! is_array($stat) || ! isset($stat['size'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $stat['size'];
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ class MimeType
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => 'text/plain',
|
||||
'markdown' => 'text/markdown',
|
||||
'md' => 'text/markdown',
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => 'application/xml',
|
||||
@@ -185,6 +187,7 @@ class MimeType
|
||||
'odm' => 'application/vnd.oasis.opendocument.text-master',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'ott' => 'application/vnd.oasis.opendocument.text-template',
|
||||
'webp' => 'image/webp',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user