add precheck in a few more places

This commit is contained in:
terrafrost 2021-08-29 11:41:32 -05:00
parent 19e7737ead
commit 4102bbaccc

View File

@ -829,6 +829,10 @@ class Net_SFTP extends Net_SSH2
*/
function realpath($path)
{
if (!$this->_precheck()) {
return false;
}
return $this->_realpath($path);
}
@ -1293,10 +1297,6 @@ class Net_SFTP extends Net_SSH2
*/
function size($filename)
{
if (!$this->_precheck()) {
return false;
}
$result = $this->stat($filename);
if ($result === false) {
return false;
@ -2693,6 +2693,10 @@ SFTP v6 changes (from v5)
function file_exists($path)
{
if ($this->use_stat_cache) {
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path);
$result = $this->_query_stat_cache($path);
@ -2763,6 +2767,10 @@ SFTP v6 changes (from v5)
*/
function is_readable($path)
{
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path);
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_READ, 0);
@ -2791,6 +2799,10 @@ SFTP v6 changes (from v5)
*/
function is_writable($path)
{
if (!$this->_precheck()) {
return false;
}
$path = $this->_realpath($path);
$packet = pack('Na*N2', strlen($path), $path, NET_SFTP_OPEN_WRITE, 0);
@ -2971,6 +2983,10 @@ SFTP v6 changes (from v5)
*/
function _get_xstat_cache_prop($path, $prop, $type)
{
if (!$this->_precheck()) {
return false;
}
if ($this->use_stat_cache) {
$path = $this->_realpath($path);
@ -3000,6 +3016,10 @@ SFTP v6 changes (from v5)
*/
function rename($oldname, $newname)
{
if (!$this->_precheck()) {
return false;
}
// in SFTP v5+
// Add support for better control of the rename operation.
// so we'll just need to add \0\0\0\0 after