mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
support append for smbclient backend
This commit is contained in:
parent
065daa49cb
commit
aa6214a257
2 changed files with 14 additions and 8 deletions
|
|
@ -357,7 +357,20 @@ class Share extends AbstractShare {
|
||||||
* @throws \Icewind\SMB\Exception\DependencyException
|
* @throws \Icewind\SMB\Exception\DependencyException
|
||||||
*/
|
*/
|
||||||
public function append($target) {
|
public function append($target) {
|
||||||
throw new DependencyException('php-libsmbclient is required for append');
|
$target = $this->escapePath($target);
|
||||||
|
// since returned stream is closed by the caller we need to create a new instance
|
||||||
|
// since we can't re-use the same file descriptor over multiple calls
|
||||||
|
$connection = $this->getConnection();
|
||||||
|
|
||||||
|
$fh = $connection->getFileInputStream();
|
||||||
|
$connection->write('reput ' . $this->system->getFD(4) . ' ' . $target);
|
||||||
|
$connection->write('exit');
|
||||||
|
|
||||||
|
// use a close callback to ensure the upload is finished before continuing
|
||||||
|
// this also serves as a way to keep the connection in scope
|
||||||
|
return CallbackWrapper::wrap($fh, null, null, function () use ($connection, $target) {
|
||||||
|
$connection->close(false); // dont terminate, give the upload some time
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,6 @@ class ShareTest extends AbstractShareTest {
|
||||||
$this->share->mkdir($this->root);
|
$this->share->mkdir($this->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\DependencyException
|
|
||||||
*/
|
|
||||||
public function testAppendStream() {
|
|
||||||
$this->share->append($this->root . '/foo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Icewind\SMB\Exception\ConnectException
|
* @expectedException \Icewind\SMB\Exception\ConnectException
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue