Skip to content

Commit

Permalink
Bump icewind/streams from 0.7.1 to 0.7.2
Browse files Browse the repository at this point in the history
Bumps [icewind/streams](https://github.com/icewind1991/Streams) from 0.7.1 to 0.7.2.
- [Release notes](https://github.com/icewind1991/Streams/releases)
- [Commits](icewind1991/Streams@v0.7.1...v0.7.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
dependabot-preview[bot] authored and ChristophWurst committed Dec 23, 2020
1 parent aea1df9 commit 0ecadf3
Show file tree
Hide file tree
Showing 23 changed files with 380 additions and 227 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"doctrine/dbal": "2.12.0",
"guzzlehttp/guzzle": "6.5.2",
"icewind/searchdav": "^2.0.0",
"icewind/streams": "v0.7.1",
"icewind/streams": "v0.7.2",
"league/flysystem": "^1.0",
"microsoft/azure-storage-blob": "1.5.0",
"nextcloud/lognormalizer": "^1.0",
Expand Down
4 changes: 2 additions & 2 deletions composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => '455f47df98504ef1336cd9e4c5b59c60903ebb22',
'reference' => 'aea1df9dcc0ae1b774e15edf07a470198b952e45',
'name' => 'nextcloud/3rdparty',
),
'versions' =>
Expand Down Expand Up @@ -284,7 +284,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => '455f47df98504ef1336cd9e4c5b59c60903ebb22',
'reference' => 'aea1df9dcc0ae1b774e15edf07a470198b952e45',
),
'nextcloud/lognormalizer' =>
array (
Expand Down
5 changes: 5 additions & 0 deletions composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1320,14 +1320,19 @@
'Icewind\\Streams\\DirectoryFilter' => $vendorDir . '/icewind/streams/src/DirectoryFilter.php',
'Icewind\\Streams\\DirectoryWrapper' => $vendorDir . '/icewind/streams/src/DirectoryWrapper.php',
'Icewind\\Streams\\File' => $vendorDir . '/icewind/streams/src/File.php',
'Icewind\\Streams\\HashWrapper' => $vendorDir . '/icewind/streams/src/HashWrapper.php',
'Icewind\\Streams\\IteratorDirectory' => $vendorDir . '/icewind/streams/src/IteratorDirectory.php',
'Icewind\\Streams\\NullWrapper' => $vendorDir . '/icewind/streams/src/NullWrapper.php',
'Icewind\\Streams\\Path' => $vendorDir . '/icewind/streams/src/Path.php',
'Icewind\\Streams\\PathWrapper' => $vendorDir . '/icewind/streams/src/PathWrapper.php',
'Icewind\\Streams\\ReadHashWrapper' => $vendorDir . '/icewind/streams/src/ReadHashWrapper.php',
'Icewind\\Streams\\RetryWrapper' => $vendorDir . '/icewind/streams/src/RetryWrapper.php',
'Icewind\\Streams\\SeekableWrapper' => $vendorDir . '/icewind/streams/src/SeekableWrapper.php',
'Icewind\\Streams\\Url' => $vendorDir . '/icewind/streams/src/Url.php',
'Icewind\\Streams\\UrlCallback' => $vendorDir . '/icewind/streams/src/UrlCallback.php',
'Icewind\\Streams\\Wrapper' => $vendorDir . '/icewind/streams/src/Wrapper.php',
'Icewind\\Streams\\WrapperHandler' => $vendorDir . '/icewind/streams/src/WrapperHandler.php',
'Icewind\\Streams\\WriteHashWrapper' => $vendorDir . '/icewind/streams/src/WriteHashWrapper.php',
'JmesPath\\AstRuntime' => $vendorDir . '/mtdowling/jmespath.php/src/AstRuntime.php',
'JmesPath\\CompilerRuntime' => $vendorDir . '/mtdowling/jmespath.php/src/CompilerRuntime.php',
'JmesPath\\DebugRuntime' => $vendorDir . '/mtdowling/jmespath.php/src/DebugRuntime.php',
Expand Down
5 changes: 5 additions & 0 deletions composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1821,14 +1821,19 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652
'Icewind\\Streams\\DirectoryFilter' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryFilter.php',
'Icewind\\Streams\\DirectoryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryWrapper.php',
'Icewind\\Streams\\File' => __DIR__ . '/..' . '/icewind/streams/src/File.php',
'Icewind\\Streams\\HashWrapper' => __DIR__ . '/..' . '/icewind/streams/src/HashWrapper.php',
'Icewind\\Streams\\IteratorDirectory' => __DIR__ . '/..' . '/icewind/streams/src/IteratorDirectory.php',
'Icewind\\Streams\\NullWrapper' => __DIR__ . '/..' . '/icewind/streams/src/NullWrapper.php',
'Icewind\\Streams\\Path' => __DIR__ . '/..' . '/icewind/streams/src/Path.php',
'Icewind\\Streams\\PathWrapper' => __DIR__ . '/..' . '/icewind/streams/src/PathWrapper.php',
'Icewind\\Streams\\ReadHashWrapper' => __DIR__ . '/..' . '/icewind/streams/src/ReadHashWrapper.php',
'Icewind\\Streams\\RetryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/RetryWrapper.php',
'Icewind\\Streams\\SeekableWrapper' => __DIR__ . '/..' . '/icewind/streams/src/SeekableWrapper.php',
'Icewind\\Streams\\Url' => __DIR__ . '/..' . '/icewind/streams/src/Url.php',
'Icewind\\Streams\\UrlCallback' => __DIR__ . '/..' . '/icewind/streams/src/UrlCallback.php',
'Icewind\\Streams\\Wrapper' => __DIR__ . '/..' . '/icewind/streams/src/Wrapper.php',
'Icewind\\Streams\\WrapperHandler' => __DIR__ . '/..' . '/icewind/streams/src/WrapperHandler.php',
'Icewind\\Streams\\WriteHashWrapper' => __DIR__ . '/..' . '/icewind/streams/src/WriteHashWrapper.php',
'JmesPath\\AstRuntime' => __DIR__ . '/..' . '/mtdowling/jmespath.php/src/AstRuntime.php',
'JmesPath\\CompilerRuntime' => __DIR__ . '/..' . '/mtdowling/jmespath.php/src/CompilerRuntime.php',
'JmesPath\\DebugRuntime' => __DIR__ . '/..' . '/mtdowling/jmespath.php/src/DebugRuntime.php',
Expand Down
4 changes: 2 additions & 2 deletions composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => '455f47df98504ef1336cd9e4c5b59c60903ebb22',
'reference' => 'aea1df9dcc0ae1b774e15edf07a470198b952e45',
'name' => 'nextcloud/3rdparty',
),
'versions' =>
Expand Down Expand Up @@ -261,7 +261,7 @@
'aliases' =>
array (
),
'reference' => '455f47df98504ef1336cd9e4c5b59c60903ebb22',
'reference' => 'aea1df9dcc0ae1b774e15edf07a470198b952e45',
),
'nextcloud/lognormalizer' =>
array (
Expand Down
2 changes: 2 additions & 0 deletions icewind/streams/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
vendor
composer.lock
build
example.php
36 changes: 17 additions & 19 deletions icewind/streams/src/CallbackWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,28 @@ class CallbackWrapper extends Wrapper {
* Wraps a stream with the provided callbacks
*
* @param resource $source
* @param callable $read (optional)
* @param callable $write (optional)
* @param callable $close (optional)
* @param callable $readDir (optional)
* @return resource
* @param callable|null $read (optional)
* @param callable|null $write (optional)
* @param callable|null $close (optional)
* @param callable|null $readDir (optional)
* @param callable|null $preClose (optional)
* @return resource|bool
*
* @throws \BadMethodCallException
*/
public static function wrap($source, $read = null, $write = null, $close = null, $readDir = null, $preClose = null) {
$context = stream_context_create(array(
'callback' => array(
'source' => $source,
'read' => $read,
'write' => $write,
'close' => $close,
'readDir' => $readDir,
'preClose' => $preClose,
)
));
return Wrapper::wrapSource($source, $context, 'callback', '\Icewind\Streams\CallbackWrapper');
$context = [
'source' => $source,
'read' => $read,
'write' => $write,
'close' => $close,
'readDir' => $readDir,
'preClose' => $preClose,
];
return self::wrapSource($source, $context);
}

protected function open() {
$context = $this->loadContext('callback');
$context = $this->loadContext();

$this->readCallback = $context['read'];
$this->writeCallback = $context['write'];
Expand Down Expand Up @@ -112,7 +110,7 @@ public function stream_write($data) {

public function stream_close() {
if (is_callable($this->preCloseCallback)) {
call_user_func($this->preCloseCallback, $this->loadContext('callback')['source']);
call_user_func($this->preCloseCallback, $this->source);
// prevent further calls by potential PHP 7 GC ghosts
$this->preCloseCallback = null;
}
Expand Down
15 changes: 6 additions & 9 deletions icewind/streams/src/CountWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,22 @@ class CountWrapper extends Wrapper {
*
* @param resource $source
* @param callable $callback
* @return resource
* @return resource|bool
*
* @throws \BadMethodCallException
*/
public static function wrap($source, $callback) {
if (!is_callable($callback)) {
throw new \InvalidArgumentException('Invalid or missing callback');
}
$context = stream_context_create(array(
'count' => array(
'source' => $source,
'callback' => $callback
)
));
return Wrapper::wrapSource($source, $context, 'callback', '\Icewind\Streams\CountWrapper');
return self::wrapSource($source, [
'source' => $source,
'callback' => $callback
]);
}

protected function open() {
$context = $this->loadContext('count');
$context = $this->loadContext();
$this->callback = $context['callback'];
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion icewind/streams/src/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Directory {
public function dir_opendir($path, $options);

/**
* @return string
* @return string|bool
*/
public function dir_readdir();

Expand Down
17 changes: 7 additions & 10 deletions icewind/streams/src/DirectoryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DirectoryFilter extends DirectoryWrapper {
* @return bool
*/
public function dir_opendir($path, $options) {
$context = $this->loadContext('filter');
$context = $this->loadContext();
$this->filter = $context['filter'];
return true;
}
Expand All @@ -36,7 +36,7 @@ public function dir_opendir($path, $options) {
public function dir_readdir() {
$file = readdir($this->source);
$filter = $this->filter;
// keep reading untill we have an accepted entry or we're at the end of the folder
// keep reading until we have an accepted entry or we're at the end of the folder
while ($file !== false && $filter($file) === false) {
$file = readdir($this->source);
}
Expand All @@ -46,15 +46,12 @@ public function dir_readdir() {
/**
* @param resource $source
* @param callable $filter
* @return resource
* @return resource|bool
*/
public static function wrap($source, callable $filter) {
$options = array(
'filter' => array(
'source' => $source,
'filter' => $filter
)
);
return self::wrapWithOptions($options, '\Icewind\Streams\DirectoryFilter');
return self::wrapSource($source, [
'source' => $source,
'filter' => $filter
]);
}
}
49 changes: 4 additions & 45 deletions icewind/streams/src/DirectoryWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,9 @@

namespace Icewind\Streams;

class DirectoryWrapper implements Directory {
/**
* @var resource
*/
public $context;

/**
* @var resource
*/
protected $source;

/**
* Load the source from the stream context and return the context options
*
* @param string $name
* @return array
* @throws \Exception
*/
protected function loadContext($name) {
$context = stream_context_get_options($this->context);
if (isset($context[$name])) {
$context = $context[$name];
} else {
throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
}
if (isset($context['source']) and is_resource($context['source'])) {
$this->source = $context['source'];
} else {
throw new \BadMethodCallException('Invalid context, source not set');
}
return $context;
class DirectoryWrapper extends Wrapper implements Directory {
public function stream_open($path, $mode, $options, &$opened_path) {
return false;
}

/**
Expand All @@ -46,7 +18,7 @@ protected function loadContext($name) {
* @return bool
*/
public function dir_opendir($path, $options) {
$this->loadContext('dir');
$this->loadContext();
return true;
}

Expand All @@ -72,17 +44,4 @@ public function dir_rewinddir() {
rewinddir($this->source);
return true;
}

/**
* @param array $options the options for the context to wrap the stream with
* @param string $class
* @return resource
*/
protected static function wrapWithOptions($options, $class) {
$context = stream_context_create($options);
stream_wrapper_register('dirwrapper', $class);
$wrapped = opendir('dirwrapper://', $context);
stream_wrapper_unregister('dirwrapper');
return $wrapped;
}
}
80 changes: 80 additions & 0 deletions icewind/streams/src/HashWrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\Streams;


abstract class HashWrapper extends Wrapper {

/**
* @var callable
*/
private $callback;

/**
* @var resource
*/
private $hashContext;

/**
* Wraps a stream to make it seekable
*
* @param resource $source
* @param string $hash
* @param callable $callback
* @return resource|bool
*
* @throws \BadMethodCallException
*/
public static function wrap($source, $hash, $callback) {
$context = [
'hash' => $hash,
'callback' => $callback,
];
return self::wrapSource($source, $context);
}

public function dir_opendir($path, $options) {
return false;
}

public function stream_open($path, $mode, $options, &$opened_path) {
$context = $this->loadContext();
$this->callback = $context['callback'];
$this->hashContext = hash_init($context['hash']);
return true;
}

protected function updateHash($data) {
hash_update($this->hashContext, $data);
}

public function stream_close() {
$hash = hash_final($this->hashContext);
if ($this->hashContext !== false && is_callable($this->callback)) {
call_user_func($this->callback, $hash);
}
return parent::stream_close();
}

}
Loading

0 comments on commit 0ecadf3

Please sign in to comment.