Merge pull request #20363 from nextcloud/smb-3.2.3

update icewind/smb to 3.2.3
This commit is contained in:
John Molakvoæ 2020-04-09 08:16:43 +02:00 committed by GitHub
commit 732a239cfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 70 additions and 27 deletions

View File

@ -9,6 +9,6 @@
},
"require": {
"icewind/streams": "0.7.1",
"icewind/smb": "3.2.1"
"icewind/smb": "3.2.3"
}
}

View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "adc3b3531ee8503b485092e60c569b42",
"content-hash": "ef0d9929f5f25696e010d5733eb51fbb",
"packages": [
{
"name": "icewind/smb",
"version": "v3.2.1",
"version": "v3.2.3",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
"reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878"
"reference": "db50bb51bd0a0e55506e82cf439a9ecd232f64d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/db50bb51bd0a0e55506e82cf439a9ecd232f64d4",
"reference": "db50bb51bd0a0e55506e82cf439a9ecd232f64d4",
"shasum": ""
},
"require": {
@ -46,7 +46,7 @@
}
],
"description": "php wrapper for smbclient and libsmbclient-php",
"time": "2020-03-24T18:19:18+00:00"
"time": "2020-04-08T15:20:22+00:00"
},
{
"name": "icewind/streams",

View File

@ -16,8 +16,10 @@ return array(
'Icewind\\SMB\\Exception\\AlreadyExistsException' => $vendorDir . '/icewind/smb/src/Exception/AlreadyExistsException.php',
'Icewind\\SMB\\Exception\\AuthenticationException' => $vendorDir . '/icewind/smb/src/Exception/AuthenticationException.php',
'Icewind\\SMB\\Exception\\ConnectException' => $vendorDir . '/icewind/smb/src/Exception/ConnectException.php',
'Icewind\\SMB\\Exception\\ConnectionAbortedException' => $vendorDir . '/icewind/smb/src/Exception/ConnectionAbortedException.php',
'Icewind\\SMB\\Exception\\ConnectionException' => $vendorDir . '/icewind/smb/src/Exception/ConnectionException.php',
'Icewind\\SMB\\Exception\\ConnectionRefusedException' => $vendorDir . '/icewind/smb/src/Exception/ConnectionRefusedException.php',
'Icewind\\SMB\\Exception\\ConnectionResetException' => $vendorDir . '/icewind/smb/src/Exception/ConnectionResetException.php',
'Icewind\\SMB\\Exception\\DependencyException' => $vendorDir . '/icewind/smb/src/Exception/DependencyException.php',
'Icewind\\SMB\\Exception\\Exception' => $vendorDir . '/icewind/smb/src/Exception/Exception.php',
'Icewind\\SMB\\Exception\\FileInUseException' => $vendorDir . '/icewind/smb/src/Exception/FileInUseException.php',

View File

@ -46,8 +46,10 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
'Icewind\\SMB\\Exception\\AlreadyExistsException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/AlreadyExistsException.php',
'Icewind\\SMB\\Exception\\AuthenticationException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/AuthenticationException.php',
'Icewind\\SMB\\Exception\\ConnectException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ConnectException.php',
'Icewind\\SMB\\Exception\\ConnectionAbortedException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ConnectionAbortedException.php',
'Icewind\\SMB\\Exception\\ConnectionException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ConnectionException.php',
'Icewind\\SMB\\Exception\\ConnectionRefusedException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ConnectionRefusedException.php',
'Icewind\\SMB\\Exception\\ConnectionResetException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ConnectionResetException.php',
'Icewind\\SMB\\Exception\\DependencyException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/DependencyException.php',
'Icewind\\SMB\\Exception\\Exception' => __DIR__ . '/..' . '/icewind/smb/src/Exception/Exception.php',
'Icewind\\SMB\\Exception\\FileInUseException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/FileInUseException.php',

View File

@ -1,17 +1,17 @@
[
{
"name": "icewind/smb",
"version": "v3.2.1",
"version_normalized": "3.2.1.0",
"version": "v3.2.3",
"version_normalized": "3.2.3.0",
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
"reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878"
"reference": "db50bb51bd0a0e55506e82cf439a9ecd232f64d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"reference": "5330edcc579a2dcc4759b8e5779eb5aa3385a878",
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/db50bb51bd0a0e55506e82cf439a9ecd232f64d4",
"reference": "db50bb51bd0a0e55506e82cf439a9ecd232f64d4",
"shasum": ""
},
"require": {
@ -22,7 +22,7 @@
"friendsofphp/php-cs-fixer": "^2.13",
"phpunit/phpunit": "^7.0"
},
"time": "2020-03-24T18:19:18+00:00",
"time": "2020-04-08T15:20:22+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2020 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class ConnectionAbortedException extends ConnectException {
}

View File

@ -0,0 +1,11 @@
<?php
/**
* Copyright (c) 2020 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class ConnectionResetException extends ConnectException {
}

View File

@ -197,12 +197,14 @@ class NativeShare extends AbstractShare {
*/
public function put($source, $target) {
$sourceHandle = fopen($source, 'rb');
$targetHandle = $this->getState()->create($this->buildUrl($target));
$targetUrl = $this->buildUrl($target);
$targetHandle = $this->getState()->create($targetUrl);
while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
$this->getState()->write($targetHandle, $data);
$this->getState()->write($targetHandle, $data, $targetUrl);
}
$this->getState()->close($targetHandle);
$this->getState()->close($targetHandle, $targetUrl);
return true;
}
@ -236,14 +238,14 @@ class NativeShare extends AbstractShare {
} else {
$reason = 'Unknown error';
}
$this->getState()->close($sourceHandle);
$this->getState()->close($sourceHandle, $this->buildUrl($source));
throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
}
while ($data = $this->getState()->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
fwrite($targetHandle, $data);
}
$this->getState()->close($sourceHandle);
$this->getState()->close($sourceHandle, $this->buildUrl($source));
return true;
}

View File

@ -16,6 +16,7 @@ use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\HostDownException;
use Icewind\SMB\Exception\InvalidArgumentException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\ConnectionAbortedException;
use Icewind\SMB\Exception\NoRouteToHostException;
use Icewind\SMB\Exception\NotEmptyException;
use Icewind\SMB\Exception\NotFoundException;
@ -49,6 +50,7 @@ class NativeState {
22 => InvalidArgumentException::class,
28 => OutOfSpaceException::class,
39 => NotEmptyException::class,
103 => ConnectionAbortedException::class,
104 => ConnectionResetException::class,
110 => TimedOutException::class,
111 => ConnectionRefusedException::class,
@ -238,13 +240,14 @@ class NativeState {
/**
* @param resource $file
* @param string $data
* @param string $path
* @param int $length
* @return int
*/
public function write($file, $data, $length = null) {
public function write($file, $data, $path, $length = null) {
$result = @smbclient_write($this->state, $file, $data, $length);
$this->testResult($result, $file);
$this->testResult($result, $path);
return $result;
}
@ -273,10 +276,10 @@ class NativeState {
return $result;
}
public function close($file) {
public function close($file, $path) {
$result = @smbclient_close($this->state, $file);
$this->testResult($result, $file);
$this->testResult($result, $path);
return $result;
}

View File

@ -61,7 +61,11 @@ class NativeStream implements File {
}
public function stream_close() {
return $this->state->close($this->handle);
try {
return $this->state->close($this->handle, $this->url);
} catch (\Exception $e) {
return false;
}
}
public function stream_eof() {
@ -110,7 +114,7 @@ class NativeStream implements File {
}
public function stream_write($data) {
return $this->state->write($this->handle, $data);
return $this->state->write($this->handle, $data, $this->url);
}
public function stream_truncate($size) {

View File

@ -61,7 +61,7 @@ class NativeWriteStream extends NativeStream {
private function flushWrite() {
rewind($this->writeBuffer);
$this->state->write($this->handle, stream_get_contents($this->writeBuffer));
$this->state->write($this->handle, stream_get_contents($this->writeBuffer), $this->url);
$this->writeBuffer = fopen('php://memory', 'r+');
$this->bufferSize = 0;
}
@ -79,8 +79,13 @@ class NativeWriteStream extends NativeStream {
}
public function stream_close() {
try {
$this->flushWrite();
return parent::stream_close();
$flushResult = true;
} catch (\Exception $e) {
$flushResult = false;
}
return parent::stream_close() && $flushResult;
}
public function stream_tell() {

View File

@ -14,11 +14,14 @@ use Icewind\SMB\Exception\DependencyException;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\InvalidRequestException;
use Icewind\SMB\IFileInfo;
use Icewind\SMB\INotifyHandler;
use Icewind\SMB\IServer;
use Icewind\SMB\ISystem;
use Icewind\Streams\CallbackWrapper;
use Icewind\SMB\Native\NativeShare;
use Icewind\SMB\Native\NativeServer;
class Share extends AbstractShare {
/**