Merge branch '2.0'

* 2.0:
  SFTP: don't start in local file middle when uploading to middle of the remote file
  Tests/SFTP: updates to newly added unit test
  SFTP: backport DavidAnderson684's changes to 1.0 branch
  add unit test demo'ing issue # 830
This commit is contained in:
Andreas Fischer 2015-09-30 17:28:03 +02:00
commit 0ba1a04c05
2 changed files with 24 additions and 4 deletions

View File

@ -1877,10 +1877,7 @@ class SFTP extends SSH2
if ($local_start >= 0) {
fseek($fp, $local_start);
} elseif ($mode & self::RESUME_START) {
// do nothing
} else {
fseek($fp, $offset);
$size-= $local_start;
}
} elseif ($dataCallback) {
$size = 0;

View File

@ -651,5 +651,28 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$this->assertSame($stat['type'], NET_SFTP_TYPE_SYMLINK);
$sftp->enableStatCache();
return $sftp;
}
/**
* @depends testStatVsLstat
* @group github830
*/
public function testUploadOffsets($sftp)
{
$sftp->put('offset.txt', 'res.txt', SFTP::SOURCE_LOCAL_FILE, 0, 10);
$this->assertSame(
substr(self::$exampleData, 10),
$sftp->get('offset.txt'),
'Failed asserting that portions of a file could be uploaded.'
);
$sftp->put('offset.txt', 'res.txt', SFTP::SOURCE_LOCAL_FILE, self::$exampleDataLength - 100);
$this->assertSame(
substr(self::$exampleData, 10, -90) . self::$exampleData,
$sftp->get('offset.txt'),
'Failed asserting that you could upload into the middle of a file.'
);
}
}