mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-26 00:28:27 +00:00
delete of non-existent folder returns true when it used to ret
This commit is contained in:
parent
c4ec1ea069
commit
24845ccbcc
@ -1105,6 +1105,12 @@ class Net_SFTP extends Net_SSH2
|
|||||||
{
|
{
|
||||||
$files = $this->_list($dir, false);
|
$files = $this->_list($dir, false);
|
||||||
|
|
||||||
|
// If we get an int back, then that is an "unexpected" status.
|
||||||
|
// We do not have a file list, so return false.
|
||||||
|
if (is_int($files)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$recursive || $files === false) {
|
if (!$recursive || $files === false) {
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
@ -1140,6 +1146,13 @@ class Net_SFTP extends Net_SSH2
|
|||||||
function rawlist($dir = '.', $recursive = false)
|
function rawlist($dir = '.', $recursive = false)
|
||||||
{
|
{
|
||||||
$files = $this->_list($dir, true);
|
$files = $this->_list($dir, true);
|
||||||
|
|
||||||
|
// If we get an int back, then that is an "unexpected" status.
|
||||||
|
// We do not have a file list, so return false.
|
||||||
|
if (is_int($files)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$recursive || $files === false) {
|
if (!$recursive || $files === false) {
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
@ -1207,8 +1220,12 @@ class Net_SFTP extends Net_SSH2
|
|||||||
break;
|
break;
|
||||||
case NET_SFTP_STATUS:
|
case NET_SFTP_STATUS:
|
||||||
// presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
// presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
|
||||||
$this->_logError($response);
|
if (strlen($response) < 4) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
|
||||||
|
$this->_logError($response, $status);
|
||||||
|
return $status;
|
||||||
default:
|
default:
|
||||||
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
|
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
|
||||||
return false;
|
return false;
|
||||||
@ -1277,7 +1294,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
|
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
|
||||||
if ($status != NET_SFTP_STATUS_EOF) {
|
if ($status != NET_SFTP_STATUS_EOF) {
|
||||||
$this->_logError($response, $status);
|
$this->_logError($response, $status);
|
||||||
return false;
|
return $status;
|
||||||
}
|
}
|
||||||
break 2;
|
break 2;
|
||||||
default:
|
default:
|
||||||
@ -1953,7 +1970,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$entries = $this->_list($path, true);
|
$entries = $this->_list($path, true);
|
||||||
|
|
||||||
if ($entries === false) {
|
if ($entries === false || is_int($entries)) {
|
||||||
return $this->_setstat($path, $attr, false);
|
return $this->_setstat($path, $attr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2798,9 +2815,14 @@ class Net_SFTP extends Net_SSH2
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$entries = $this->_list($path, true);
|
$entries = $this->_list($path, true);
|
||||||
|
|
||||||
// normally $entries would have at least . and .. but it might not if the directories
|
// The folder does not exist at all, so we cannot delete it.
|
||||||
// permissions didn't allow reading
|
if ($entries === NET_SFTP_STATUS_NO_SUCH_FILE) {
|
||||||
if (empty($entries)) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normally $entries would have at least . and .. but it might not if the directories
|
||||||
|
// permissions didn't allow reading. If this happens then default to an empty list of files.
|
||||||
|
if ($entries === false || is_int($entries)) {
|
||||||
$entries = array();
|
$entries = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,6 +621,12 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
'Failed asserting that stat on a deleted directory returns false'
|
'Failed asserting that stat on a deleted directory returns false'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
$sftp->delete(self::$scratchDir),
|
||||||
|
'Failed asserting that non-existent directory could not ' .
|
||||||
|
'be deleted using recursive delete().'
|
||||||
|
);
|
||||||
|
|
||||||
return $sftp;
|
return $sftp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user