Skip to content

Commit

Permalink
fixup! Bump icewind/streams from 0.7.1 to 0.7.2
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Dec 28, 2020
1 parent 68c2b7c commit 14b7f51
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/private/Files/Stream/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

use Icewind\Streams\Wrapper;
use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
use function is_array;
use function stream_context_create;

class Encryption extends Wrapper {

Expand Down Expand Up @@ -192,15 +194,20 @@ public static function wrap($source, $internalPath, $fullPath, array $header,
*
* @param resource $source
* @param string $mode
* @param resource $context
* @param string $protocol
* @param string $class
* @param resource|array $context
* @param string|null $protocol
* @param string|null $class
* @return resource
* @throws \BadMethodCallException
*/
protected static function wrapSource($source, $context, $protocol, $class, $mode = 'r+') {
protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') {
try {
if ($protocol === null) {
$protocol = self::getProtocol($class);
}

stream_wrapper_register($protocol, $class);
$context = self::buildContext($protocol, $context, $source);
if (self::isDirectoryHandle($source)) {
$wrapped = opendir($protocol . '://', $context);
} else {
Expand All @@ -214,6 +221,18 @@ protected static function wrapSource($source, $context, $protocol, $class, $mode
return $wrapped;
}

/**
* @todo this is a copy of \Icewind\Streams\WrapperHandler::buildContext -> combine to one shared method?
*/
private static function buildContext($protocol, $context, $source) {
if (is_array($context)) {
$context['source'] = $source;
return stream_context_create([$protocol => $context]);
}

return $context;
}

/**
* Load the source from the stream context and return the context options
*
Expand Down

0 comments on commit 14b7f51

Please sign in to comment.