update v 1.0.7.5
This commit is contained in:
@@ -6,6 +6,7 @@ use DateTime;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\NotSupportedException;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
{
|
||||
@@ -79,6 +80,11 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected $systemType;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $alternativeRecursion = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -317,6 +323,8 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
return $this->listDirectoryContents($directory, $recursive);
|
||||
}
|
||||
|
||||
abstract protected function listDirectoryContents($directory, $recursive = false);
|
||||
|
||||
/**
|
||||
* Normalize a directory listing.
|
||||
*
|
||||
@@ -395,6 +403,11 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
protected function normalizeUnixObject($item, $base)
|
||||
{
|
||||
$item = preg_replace('#\s+#', ' ', trim($item), 7);
|
||||
|
||||
if (count(explode(' ', $item, 9)) !== 9) {
|
||||
throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
|
||||
}
|
||||
|
||||
list($permissions, /* $number */, /* $owner */, /* $group */, $size, /* $month */, /* $day */, /* $time*/, $name) = explode(' ', $item, 9);
|
||||
$type = $this->detectType($permissions);
|
||||
$path = empty($base) ? $name : $base . $this->separator . $name;
|
||||
@@ -421,6 +434,11 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
protected function normalizeWindowsObject($item, $base)
|
||||
{
|
||||
$item = preg_replace('#\s+#', ' ', trim($item), 3);
|
||||
|
||||
if (count(explode(' ', $item, 4)) !== 4) {
|
||||
throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
|
||||
}
|
||||
|
||||
list($date, $time, $size, $name) = explode(' ', $item, 4);
|
||||
$path = empty($base) ? $name : $base . $this->separator . $name;
|
||||
|
||||
|
||||
60
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
60
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace League\Flysystem\Adapter;
|
||||
|
||||
use ErrorException;
|
||||
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
@@ -22,6 +23,11 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
protected $ignorePassiveAddress = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $recurseManually = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -39,6 +45,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
'transferMode',
|
||||
'systemType',
|
||||
'ignorePassiveAddress',
|
||||
'recurseManually',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -87,6 +94,14 @@ class Ftp extends AbstractFtpAdapter
|
||||
$this->ignorePassiveAddress = $ignorePassiveAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $recurseManually
|
||||
*/
|
||||
public function setRecurseManually($recurseManually)
|
||||
{
|
||||
$this->recurseManually = $recurseManually;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the FTP server.
|
||||
*/
|
||||
@@ -306,7 +321,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
{
|
||||
// List the current directory
|
||||
$listing = ftp_nlist($connection, '.') ?: [];
|
||||
|
||||
|
||||
foreach ($listing as $key => $item) {
|
||||
if (preg_match('~^\./.*~', $item)) {
|
||||
$listing[$key] = substr($item, 2);
|
||||
@@ -347,6 +362,10 @@ class Ftp extends AbstractFtpAdapter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/^total [0-9]*$/', $listing[0])) {
|
||||
array_shift($listing);
|
||||
}
|
||||
|
||||
return $this->normalizeObject($listing[0], '');
|
||||
}
|
||||
|
||||
@@ -430,19 +449,56 @@ class Ftp extends AbstractFtpAdapter
|
||||
protected function listDirectoryContents($directory, $recursive = true)
|
||||
{
|
||||
$directory = str_replace('*', '\\*', $directory);
|
||||
|
||||
if ($recursive && $this->recurseManually) {
|
||||
return $this->listDirectoryContentsRecursive($directory);
|
||||
}
|
||||
|
||||
$options = $recursive ? '-alnR' : '-aln';
|
||||
$listing = ftp_rawlist($this->getConnection(), $options . ' ' . $directory);
|
||||
|
||||
return $listing ? $this->normalizeListing($listing, $directory) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
protected function listDirectoryContentsRecursive($directory)
|
||||
{
|
||||
$listing = $this->normalizeListing(ftp_rawlist($this->getConnection(), '-aln' . ' ' . $directory) ?: []);
|
||||
$output = [];
|
||||
|
||||
foreach ($listing as $directory) {
|
||||
$output[] = $directory;
|
||||
if ($directory['type'] !== 'dir') continue;
|
||||
|
||||
$output = array_merge($output, $this->listDirectoryContentsRecursive($directory['path']));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the connection is open.
|
||||
*
|
||||
* @return bool
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
return is_resource($this->connection) && ftp_systype($this->connection) !== false;
|
||||
try {
|
||||
return is_resource($this->connection) && ftp_rawlist($this->connection, '/') !== false;
|
||||
} catch (ErrorException $e) {
|
||||
fclose($this->connection);
|
||||
$this->connection = null;
|
||||
|
||||
if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
vendor/league/flysystem/src/Adapter/Local.php
vendored
19
vendor/league/flysystem/src/Adapter/Local.php
vendored
@@ -7,9 +7,11 @@ use FilesystemIterator;
|
||||
use finfo as Finfo;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Exception;
|
||||
use League\Flysystem\NotSupportedException;
|
||||
use League\Flysystem\UnreadableFileException;
|
||||
use League\Flysystem\Util;
|
||||
use LogicException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use SplFileInfo;
|
||||
@@ -31,8 +33,8 @@ class Local extends AbstractAdapter
|
||||
*/
|
||||
protected static $permissions = [
|
||||
'file' => [
|
||||
'public' => 0744,
|
||||
'private' => 0700,
|
||||
'public' => 0644,
|
||||
'private' => 0600,
|
||||
],
|
||||
'dir' => [
|
||||
'public' => 0755,
|
||||
@@ -69,12 +71,11 @@ class Local extends AbstractAdapter
|
||||
*/
|
||||
public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = [])
|
||||
{
|
||||
// permissionMap needs to be set before ensureDirectory() is called.
|
||||
$this->permissionMap = array_replace_recursive(static::$permissions, $permissions);
|
||||
$realRoot = $this->ensureDirectory($root);
|
||||
|
||||
if ( ! is_dir($realRoot) || ! is_readable($realRoot)) {
|
||||
throw new \LogicException('The root path ' . $root . ' is not readable.');
|
||||
throw new LogicException('The root path ' . $root . ' is not readable.');
|
||||
}
|
||||
|
||||
$this->setPathPrefix($realRoot);
|
||||
@@ -88,6 +89,8 @@ class Local extends AbstractAdapter
|
||||
* @param string $root root directory path
|
||||
*
|
||||
* @return string real path to root
|
||||
*
|
||||
* @throws Exception in case the root directory can not be created
|
||||
*/
|
||||
protected function ensureDirectory($root)
|
||||
{
|
||||
@@ -95,6 +98,10 @@ class Local extends AbstractAdapter
|
||||
$umask = umask(0);
|
||||
mkdir($root, $this->permissionMap['dir']['public'], true);
|
||||
umask($umask);
|
||||
|
||||
if ( ! is_dir($root)) {
|
||||
throw new Exception(sprintf('Impossible to create the root directory "%s".', $root));
|
||||
}
|
||||
}
|
||||
|
||||
return realpath($root);
|
||||
@@ -381,9 +388,9 @@ class Local extends AbstractAdapter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file
|
||||
* @param SplFileInfo $file
|
||||
*/
|
||||
protected function deleteFileInfoObject($file)
|
||||
protected function deleteFileInfoObject(SplFileInfo $file)
|
||||
{
|
||||
switch ($file->getType()) {
|
||||
case 'dir':
|
||||
|
||||
Reference in New Issue
Block a user