|
@@ -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
|
|
|
{
|
|
@@ -135,7 +137,7 @@ class Ftp extends AbstractFtpAdapter
|
|
|
}
|
|
|
|
|
|
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()
|
|
|
);
|
|
@@ -526,7 +528,7 @@ class Ftp extends AbstractFtpAdapter
|
|
|
*
|
|
|
* @return bool
|
|
|
*
|
|
|
- * @throws ErrorException
|
|
|
+ * @throws ConnectionErrorException
|
|
|
*/
|
|
|
public function isConnected()
|
|
|
{
|
|
@@ -534,7 +536,7 @@ class Ftp extends AbstractFtpAdapter
|
|
|
return is_resource($this->connection) && ftp_rawlist($this->connection, $this->getRoot()) !== false;
|
|
|
} catch (ErrorException $e) {
|
|
|
if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
|
|
|
- throw $e;
|
|
|
+ throw new ConnectionErrorException($e->getMessage());
|
|
|
}
|
|
|
|
|
|
return false;
|