diff --git a/src/Native/NativeShare.php b/src/Native/NativeShare.php index a757d7f..c3abfcf 100644 --- a/src/Native/NativeShare.php +++ b/src/Native/NativeShare.php @@ -326,7 +326,7 @@ class NativeShare extends AbstractShare { * @return INotifyHandler */ public function notify($path) { - // php-smbclient does support notify (https://github.com/eduardok/libsmbclient-php/issues/29) + // php-smbclient does not support notify (https://github.com/eduardok/libsmbclient-php/issues/29) // so we use the smbclient based backend for this if (!Server::available($this->server->getSystem())) { throw new DependencyException('smbclient not found in path for notify command'); diff --git a/src/Wrapped/Share.php b/src/Wrapped/Share.php index 909c8a3..af1e174 100644 --- a/src/Wrapped/Share.php +++ b/src/Wrapped/Share.php @@ -19,6 +19,8 @@ use Icewind\SMB\IServer; use Icewind\SMB\ISystem; use Icewind\SMB\TimeZoneProvider; use Icewind\Streams\CallbackWrapper; +use Icewind\SMB\Native\NativeShare; +use Icewind\SMB\Native\NativeServer; class Share extends AbstractShare { /** @@ -330,14 +332,22 @@ class Share extends AbstractShare { } /** - * Append on wrapped smbclient not supported + * Append to stream + * Note: smbclient does not support it so we use php-libsmbclient * - * @param string $source + * @param string $target * - * @throws \Icewind\SMB\Exception\InvalidRequestException - */ - public function append($source) { - throw new InvalidRequestException("Not supported, use Icewind\SMB\Native\NativeShare"); + * @throws \Icewind\SMB\Exception\DependencyException + * @throws \Icewind\SMB\Exception\NotFoundException + * @throws \Icewind\SMB\Exception\InvalidTypeException + */ + public function append($target) { + if (!NativeServer::available($this->server->getSystem())) { + throw new DependencyException('php-libsmbclient not installed'); + } + + $share = new NativeShare($this->server, $this->getName()); + return $share->append($target); } /** diff --git a/tests/AbstractShareTest.php b/tests/AbstractShareTest.php index 9af14b7..f1928ca 100644 --- a/tests/AbstractShareTest.php +++ b/tests/AbstractShareTest.php @@ -474,6 +474,21 @@ abstract class AbstractShareTest extends TestCase { unlink($tmpFile1); } + public function testAppendStream() { + $fh = $this->share->append($this->root . '/' . $name); + fwrite($fh, 'foo'); + fclose($fh); + + $fh = $this->share->append($this->root . '/' . $name); + fwrite($fh, 'bar'); + fclose($fh); + + $tmpFile1 = tempnam('/tmp', 'smb_test_'); + $this->assertEquals('foobar', file_get_contents($tmpFile1)); + $this->share->del($this->root . '/' . $name); + unlink($tmpFile1); + } + /** * @dataProvider invalidPathProvider * @expectedException \Icewind\SMB\Exception\InvalidPathException diff --git a/tests/NativeShareTest.php b/tests/NativeShareTest.php index f75e61e..ae9a008 100644 --- a/tests/NativeShareTest.php +++ b/tests/NativeShareTest.php @@ -39,19 +39,4 @@ class NativeShareTest extends AbstractShareTest { } $this->share->mkdir($this->root); } - - public function testAppendStream() { - $fh = $this->share->append($this->root . '/' . $name); - fwrite($fh, 'foo'); - fclose($fh); - - $fh = $this->share->append($this->root . '/' . $name); - fwrite($fh, 'bar'); - fclose($fh); - - $tmpFile1 = tempnam('/tmp', 'smb_test_'); - $this->assertEquals('foobar', file_get_contents($tmpFile1)); - $this->share->del($this->root . '/' . $name); - unlink($tmpFile1); - } } diff --git a/tests/ShareTest.php b/tests/ShareTest.php index 0916c82..640b6aa 100644 --- a/tests/ShareTest.php +++ b/tests/ShareTest.php @@ -57,11 +57,4 @@ class ShareTest extends AbstractShareTest { $share = $this->server->getShare($this->config->share); $share->dir($this->root); } - - /** - * @expectedException \Icewind\SMB\Exception\InvalidRequestException - */ - public function testAppendStream() { - $fh = $this->share->append($this->root . '/' . $name); - } }