mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 10:15:14 +00:00
Merge pull request #731 from terrafrost/sftp-recur-delete-stat-cache-1.0
SFTP: delete stat cache for recursive deletes / 1.0 branch * terrafrost/sftp-recur-delete-stat-cache-1.0: SFTP: update how recursive delete's update stat cache Tests/SFTP: add unit test
This commit is contained in:
commit
643103449c
@ -2218,6 +2218,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($temp), $temp))) {
|
if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($temp), $temp))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$this->_remove_from_stat_cache($temp);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
@ -2228,12 +2229,12 @@ class Net_SFTP extends Net_SSH2
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_remove_from_stat_cache($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($path), $path))) {
|
if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($path), $path))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$this->_remove_from_stat_cache($path);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
@ -565,5 +565,34 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
'Failed asserting that nonexistent scratch directory could ' .
|
'Failed asserting that nonexistent scratch directory could ' .
|
||||||
'not be deleted using rmdir().'
|
'not be deleted using rmdir().'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $sftp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testRmDirScratchNonexistent
|
||||||
|
* @group github706
|
||||||
|
*/
|
||||||
|
public function testDeleteEmptyDir($sftp)
|
||||||
|
{
|
||||||
|
$this->assertTrue(
|
||||||
|
$sftp->mkdir(self::$scratchDir),
|
||||||
|
'Failed asserting that scratch directory could ' .
|
||||||
|
'be created.'
|
||||||
|
);
|
||||||
|
$this->assertInternalType(
|
||||||
|
'array',
|
||||||
|
$sftp->stat(self::$scratchDir),
|
||||||
|
'Failed asserting that stat on an existant empty directory returns an array'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
$sftp->delete(self::$scratchDir),
|
||||||
|
'Failed asserting that empty scratch directory could ' .
|
||||||
|
'be deleted using recursive delete().'
|
||||||
|
);
|
||||||
|
$this->assertFalse(
|
||||||
|
$sftp->stat(self::$scratchDir),
|
||||||
|
'Failed asserting that stat on a deleted directory returns false'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user