updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -1,4 +1,4 @@
Copyright (c) 2013-2018 Frank de Jonge
Copyright (c) 2013-2019 Frank de Jonge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -76,6 +76,13 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
*/
protected $safeStorage;
/**
* True to enable timestamps for FTP servers that return unix-style listings
*
* @var bool
*/
protected $enableTimestampsOnUnixListings = false;
/**
* Constructor.
*
@@ -309,6 +316,18 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
return $this;
}
/**
* True to enable timestamps for FTP servers that return unix-style listings
*
* @param bool $bool
* @return $this
*/
public function setEnableTimestampsOnUnixListings($bool = false) {
$this->enableTimestampsOnUnixListings = $bool;
return $this;
}
/**
* @inheritdoc
*/
@@ -389,6 +408,18 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
/**
* Normalize a Unix file entry.
*
* Given $item contains:
* '-rw-r--r-- 1 ftp ftp 409 Aug 19 09:01 file1.txt'
*
* This function will return:
* [
* 'type' => 'file',
* 'path' => 'file1.txt',
* 'visibility' => 'public',
* 'size' => 409,
* 'timestamp' => 1566205260
* ]
*
* @param string $item
* @param string $base
*
@@ -402,7 +433,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
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);
list($permissions, /* $number */, /* $owner */, /* $group */, $size, $month, $day, $timeOrYear, $name) = explode(' ', $item, 9);
$type = $this->detectType($permissions);
$path = $base === '' ? $name : $base . $this->separator . $name;
@@ -414,7 +445,41 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
$visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
$size = (int) $size;
return compact('type', 'path', 'visibility', 'size');
$result = compact('type', 'path', 'visibility', 'size');
if ($this->enableTimestampsOnUnixListings) {
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
$result += compact('timestamp');
}
return $result;
}
/**
* Only accurate to the minute (current year), or to the day
*
* Inadequacies in timestamp accuracy are due to limitations of the FTP 'LIST' command
*
* Note: The 'MLSD' command is a machine-readable replacement for 'LIST'
* but many FTP servers do not support it :(
*
* @param string $month e.g. 'Aug'
* @param string $day e.g. '19'
* @param string $timeOrYear e.g. '09:01' OR '2015'
* @return int
*/
protected function normalizeUnixTimestamp($month, $day, $timeOrYear) {
if (is_numeric($timeOrYear)) {
$year = $timeOrYear;
$hour = '00';
$minute = '00';
$seconds = '00';
}
else {
$year = date('Y');
list($hour, $minute) = explode(':', $timeOrYear);
$seconds = '00';
}
$dateTime = DateTime::createFromFormat('Y-M-j-G:i:s', "{$year}-{$month}-{$day}-{$hour}:{$minute}:{$seconds}");
return $dateTime->getTimestamp();
}
/**

View File

@@ -53,6 +53,7 @@ class Ftp extends AbstractFtpAdapter
'ignorePassiveAddress',
'recurseManually',
'utf8',
'enableTimestampsOnUnixListings',
];
/**
@@ -380,13 +381,11 @@ class Ftp extends AbstractFtpAdapter
*/
public function getMetadata($path)
{
$connection = $this->getConnection();
if ($path === '') {
return ['type' => 'dir', 'path' => ''];
}
if (@ftp_chdir($connection, $path) === true) {
if (@ftp_chdir($this->getConnection(), $path) === true) {
$this->setConnectionRoot();
return ['type' => 'dir', 'path' => $path];

View File

@@ -106,6 +106,7 @@ class Local extends AbstractAdapter
}
umask($umask);
clearstatcache(false, $root);
if ( ! is_dir($root)) {
$errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';

View File

@@ -270,7 +270,8 @@ class Filesystem implements FilesystemInterface
$directory = Util::normalizePath($directory);
$contents = $this->getAdapter()->listContents($directory, $recursive);
return (new ContentListingFormatter($directory, $recursive))->formatListing($contents);
return (new ContentListingFormatter($directory, $recursive, $this->config->get('case_sensitive', true)))
->formatListing($contents);
}
/**

View File

@@ -13,19 +13,26 @@ class ContentListingFormatter
* @var string
*/
private $directory;
/**
* @var bool
*/
private $recursive;
/**
* @var bool
*/
private $caseSensitive;
/**
* @param string $directory
* @param bool $recursive
*/
public function __construct($directory, $recursive)
public function __construct($directory, $recursive, $caseSensitive = true)
{
$this->directory = $directory;
$this->directory = rtrim($directory, '/');
$this->recursive = $recursive;
$this->caseSensitive = $caseSensitive;
}
/**
@@ -37,14 +44,9 @@ class ContentListingFormatter
*/
public function formatListing(array $listing)
{
$listing = array_values(
array_map(
[$this, 'addPathInfo'],
array_filter($listing, [$this, 'isEntryOutOfScope'])
)
);
$listing = array_filter(array_map([$this, 'addPathInfo'], $listing), [$this, 'isEntryOutOfScope']);
return $this->sortListing($listing);
return $this->sortListing(array_values($listing));
}
private function addPathInfo(array $entry)
@@ -85,7 +87,9 @@ class ContentListingFormatter
return true;
}
return strpos($entry['path'], $this->directory . '/') === 0;
return $this->caseSensitive
? strpos($entry['path'], $this->directory . '/') === 0
: stripos($entry['path'], $this->directory . '/') === 0;
}
/**
@@ -97,7 +101,9 @@ class ContentListingFormatter
*/
private function isDirectChild(array $entry)
{
return Util::dirname($entry['path']) === $this->directory;
return $this->caseSensitive
? $entry['dirname'] === $this->directory
: strcasecmp($this->directory, $entry['dirname']) === 0;
}
/**