Merge branch '3.0'

This commit is contained in:
terrafrost 2023-06-04 10:51:36 -05:00
commit 501c96c48c
2 changed files with 22 additions and 3 deletions

View File

@ -2490,12 +2490,31 @@ class SFTP extends SSH2
return $this->get_stat_cache_prop($path, 'gid');
}
/**
* Recursively go through rawlist() output to get the total filesize
*/
private static function recursiveFilesize(array $files): int
{
$size = 0;
foreach ($files as $name => $file) {
if ($name == '.' || $name == '..') {
continue;
}
$size += is_array($file) ?
self::recursiveFilesize($file) :
$file->size;
}
return $size;
}
/**
* Gets file size
*/
public function filesize(string $path)
public function filesize(string $path, bool $recursive = false)
{
return $this->get_stat_cache_prop($path, 'size');
return !$recursive || $this->filetype($path) != 'dir' ?
$this->get_stat_cache_prop($path, 'size') :
$this->recursiveFilesize($this->rawlist($path, true));
}
/**

View File

@ -257,7 +257,7 @@ zUlir0ACPypC1Q==
$this->assertSame($data, $decrypted);
}
public function testSettingOnePadding()
public function testSettingOnePadding(): void
{
$pub = <<<HERE
-----BEGIN PUBLIC KEY-----