update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -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';
}
/**

View File

@@ -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);

View File

@@ -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];
}
/**

View File

@@ -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);
}