update 1.0.8.0
Commits for version update
This commit is contained in:
@@ -444,7 +444,8 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
|
||||
// Check for the correct date/time format
|
||||
$format = strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i';
|
||||
$timestamp = DateTime::createFromFormat($format, $date . $time)->getTimestamp();
|
||||
$dt = DateTime::createFromFormat($format, $date . $time);
|
||||
$timestamp = $dt ? $dt->getTimestamp() : (int) strtotime("$date $time");
|
||||
|
||||
if ($size === '<DIR>') {
|
||||
$type = 'dir';
|
||||
@@ -468,11 +469,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
|
||||
*/
|
||||
protected function detectSystemType($item)
|
||||
{
|
||||
if (preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item)) {
|
||||
return $this->systemType = 'windows';
|
||||
}
|
||||
|
||||
return $this->systemType = 'unix';
|
||||
return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item) ? 'windows' : 'unix';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
7
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
7
vendor/league/flysystem/src/Adapter/Ftp.php
vendored
@@ -7,6 +7,7 @@ use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\Config;
|
||||
use League\Flysystem\Util;
|
||||
use League\Flysystem\Util\MimeType;
|
||||
use RuntimeException;
|
||||
|
||||
class Ftp extends AbstractFtpAdapter
|
||||
@@ -374,11 +375,11 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
public function getMimetype($path)
|
||||
{
|
||||
if ( ! $metadata = $this->read($path)) {
|
||||
if ( ! $metadata = $this->getMetadata($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$metadata['mimetype'] = Util::guessMimeType($path, $metadata['contents']);
|
||||
$metadata['mimetype'] = MimeType::detectByFilename($path);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
@@ -414,7 +415,7 @@ class Ftp extends AbstractFtpAdapter
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
$stream = fopen('php://temp', 'w+');
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
$result = ftp_fget($this->getConnection(), $stream, $path, $this->transferMode);
|
||||
rewind($stream);
|
||||
|
||||
|
||||
14
vendor/league/flysystem/src/Adapter/Local.php
vendored
14
vendor/league/flysystem/src/Adapter/Local.php
vendored
@@ -71,6 +71,7 @@ class Local extends AbstractAdapter
|
||||
*/
|
||||
public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = [])
|
||||
{
|
||||
$root = is_link($root) ? realpath($root) : $root;
|
||||
$this->permissionMap = array_replace_recursive(static::$permissions, $permissions);
|
||||
$realRoot = $this->ensureDirectory($root);
|
||||
|
||||
@@ -96,7 +97,7 @@ class Local extends AbstractAdapter
|
||||
{
|
||||
if ( ! is_dir($root)) {
|
||||
$umask = umask(0);
|
||||
mkdir($root, $this->permissionMap['dir']['public'], true);
|
||||
@mkdir($root, $this->permissionMap['dir']['public'], true);
|
||||
umask($umask);
|
||||
|
||||
if ( ! is_dir($root)) {
|
||||
@@ -147,7 +148,7 @@ class Local extends AbstractAdapter
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$this->ensureDirectory(dirname($location));
|
||||
$stream = fopen($location, 'w+');
|
||||
$stream = fopen($location, 'w+b');
|
||||
|
||||
if ( ! $stream) {
|
||||
return false;
|
||||
@@ -172,7 +173,7 @@ class Local extends AbstractAdapter
|
||||
public function readStream($path)
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$stream = fopen($location, 'r');
|
||||
$stream = fopen($location, 'rb');
|
||||
|
||||
return compact('stream', 'path');
|
||||
}
|
||||
@@ -304,8 +305,13 @@ class Local extends AbstractAdapter
|
||||
{
|
||||
$location = $this->applyPathPrefix($path);
|
||||
$finfo = new Finfo(FILEINFO_MIME_TYPE);
|
||||
$mimetype = $finfo->file($location);
|
||||
|
||||
return ['mimetype' => $finfo->file($location)];
|
||||
if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty'])) {
|
||||
$mimetype = Util\MimeType::detectByFilename($location);
|
||||
}
|
||||
|
||||
return ['mimetype' => $mimetype];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
|
||||
namespace League\Flysystem\Adapter\Polyfill;
|
||||
|
||||
/**
|
||||
* A helper for adapters that only handle strings to provide read streams.
|
||||
*/
|
||||
trait StreamedReadingTrait
|
||||
{
|
||||
/**
|
||||
* Get the contents of a file in a stream.
|
||||
* Reads a file as a stream.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return resource|false false when not found, or a resource
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::readStream()
|
||||
*/
|
||||
public function readStream($path)
|
||||
{
|
||||
@@ -17,7 +22,7 @@ trait StreamedReadingTrait
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream = tmpfile();
|
||||
$stream = fopen('php://temp', 'w+b');
|
||||
fwrite($stream, $data['contents']);
|
||||
rewind($stream);
|
||||
$data['stream'] = $stream;
|
||||
@@ -26,12 +31,14 @@ trait StreamedReadingTrait
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Required abstract method
|
||||
|
||||
/**
|
||||
* Reads a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return resource
|
||||
* @return array|false
|
||||
*
|
||||
* @see League\Flysystem\ReadInterface::read()
|
||||
*/
|
||||
abstract public function read($path);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ trait ConfigAwareTrait
|
||||
*/
|
||||
protected function setConfig($config)
|
||||
{
|
||||
$this->config = $config ? Util::ensureConfig($config) : null;
|
||||
$this->config = $config ? Util::ensureConfig($config) : new Config;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,10 +29,6 @@ trait ConfigAwareTrait
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
if ($this->config === null) {
|
||||
return $this->config = new Config;
|
||||
}
|
||||
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class FileExistsException extends Exception
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path which was not found.
|
||||
* Get the path which was found.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
10
vendor/league/flysystem/src/Filesystem.php
vendored
10
vendor/league/flysystem/src/Filesystem.php
vendored
@@ -8,6 +8,8 @@ use League\Flysystem\Util\ContentListingFormatter;
|
||||
|
||||
/**
|
||||
* @method array getWithMetadata(string $path, array $metadata)
|
||||
* @method bool forceCopy(string $path, string $newpath)
|
||||
* @method bool forceRename(string $path, string $newpath)
|
||||
* @method array listFiles(string $path = '', boolean $recursive = false)
|
||||
* @method array listPaths(string $path = '', boolean $recursive = false)
|
||||
* @method array listWith(array $keys = [], $directory = '', $recursive = false)
|
||||
@@ -374,10 +376,12 @@ class Filesystem implements FilesystemInterface
|
||||
* @param string $path path to file
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertPresent($path)
|
||||
{
|
||||
if ( ! $this->has($path)) {
|
||||
if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
|
||||
throw new FileNotFoundException($path);
|
||||
}
|
||||
}
|
||||
@@ -388,10 +392,12 @@ class Filesystem implements FilesystemInterface
|
||||
* @param string $path path to file
|
||||
*
|
||||
* @throws FileExistsException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assertAbsent($path)
|
||||
{
|
||||
if ($this->has($path)) {
|
||||
if ($this->config->get('disable_asserts', false) === false && $this->has($path)) {
|
||||
throw new FileExistsException($path);
|
||||
}
|
||||
}
|
||||
|
||||
4
vendor/league/flysystem/src/MountManager.php
vendored
4
vendor/league/flysystem/src/MountManager.php
vendored
@@ -39,8 +39,8 @@ use LogicException;
|
||||
* @method array|false getMetadata($path)
|
||||
* @method Handler get($path, Handler $handler = null)
|
||||
* @method Filesystem flushCache()
|
||||
* @method assertPresent($path)
|
||||
* @method assertAbsent($path)
|
||||
* @method void assertPresent($path)
|
||||
* @method void assertAbsent($path)
|
||||
* @method Filesystem addPlugin(PluginInterface $plugin)
|
||||
*/
|
||||
class MountManager
|
||||
|
||||
42
vendor/league/flysystem/src/Plugin/ForcedCopy.php
vendored
Normal file
42
vendor/league/flysystem/src/Plugin/ForcedCopy.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ForcedCopy extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'forceCopy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a file, overwriting any existing files.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function handle($path, $newpath)
|
||||
{
|
||||
try {
|
||||
$deleted = $this->filesystem->delete($newpath);
|
||||
} catch (FileNotFoundException $e) {
|
||||
// The destination path does not exist. That's ok.
|
||||
$deleted = true;
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
return $this->filesystem->copy($path, $newpath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
42
vendor/league/flysystem/src/Plugin/ForcedRename.php
vendored
Normal file
42
vendor/league/flysystem/src/Plugin/ForcedRename.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace League\Flysystem\Plugin;
|
||||
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ForcedRename extends AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'forceRename';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a file, overwriting the destination if it exists.
|
||||
*
|
||||
* @param string $path Path to the existing file.
|
||||
* @param string $newpath The new path of the file.
|
||||
*
|
||||
* @throws FileNotFoundException Thrown if $path does not exist.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function handle($path, $newpath)
|
||||
{
|
||||
try {
|
||||
$deleted = $this->filesystem->delete($newpath);
|
||||
} catch (FileNotFoundException $e) {
|
||||
// The destination path does not exist. That's ok.
|
||||
$deleted = true;
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
return $this->filesystem->rename($path, $newpath);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user