Merge branch '3.0'

This commit is contained in:
terrafrost 2020-12-19 01:02:39 -06:00
commit 1d75d080f1
3 changed files with 33 additions and 2 deletions

View File

@ -1867,8 +1867,6 @@ class SFTP extends SSH2
return false;
}
$this->remove_from_stat_cache($remote_file);
$flags = NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE;
// according to the SFTP specs, NET_SFTP_OPEN_APPEND should "force all writes to append data at the end of the file."
// in practice, it doesn't seem to do that.
@ -1885,6 +1883,8 @@ class SFTP extends SSH2
$flags|= NET_SFTP_OPEN_TRUNCATE;
}
$this->remove_from_stat_cache($remote_file);
$packet = Strings::packSSH2('sNN', $remote_file, $flags, 0);
if (!$this->send_sftp_packet(NET_SFTP_OPEN, $packet)) {
return false;

View File

@ -55,6 +55,20 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
$this->assertEquals(['.', '..'], array_slice($dirs, 0, 2));
}
/**
* @group github1552
*/
public function testStreamSelect()
{
$context = stream_context_create([
'sftp' => ['session' => $this->sftp],
]);
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
$read = [$fp];
$write = $except = null;
stream_select($read, $write, $except, 0);
}
protected function buildUrl($suffix)
{
return sprintf(

View File

@ -167,6 +167,23 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
'Failed asserting that get() returns expected example data.'
);
$this->assertTrue(
$sftp->put('file1.txt', 'xxx', SFTP::RESUME),
'Failed asserting that an upload could be successfully resumed'
);
$this->assertSame(
self::$exampleDataLength + 3,
$sftp->filesize('file1.txt'),
'Failed asserting that put example data has the expected length'
);
$this->assertSame(
self::$exampleData . 'zzz',
$sftp->get('file1.txt'),
'Failed asserting that get() returns expected example data.'
);
return $sftp;
}