Fix #1143 Add additional check to skip broken symlinks to avoid RuntimeException: SplFileInfo::getSize(): stat failed
This commit is contained in:
parent
2e2b5a179a
commit
7ae53cfd63
|
@ -268,7 +268,7 @@ class Filesystem {
|
||||||
/**
|
/**
|
||||||
* Get Size of file or directory in bytes
|
* Get Size of file or directory in bytes
|
||||||
* @param [string] $fileOrDirectory
|
* @param [string] $fileOrDirectory
|
||||||
* @return [int|bool [bytes or false on error]
|
* @return [int|bool] [bytes or false on error]
|
||||||
*/
|
*/
|
||||||
public static function getSize($fileOrDirectory) {
|
public static function getSize($fileOrDirectory) {
|
||||||
// Files
|
// Files
|
||||||
|
@ -278,9 +278,11 @@ class Filesystem {
|
||||||
// Directories
|
// Directories
|
||||||
if (file_exists($fileOrDirectory)) {
|
if (file_exists($fileOrDirectory)) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fileOrDirectory)) as $file){
|
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fileOrDirectory, FilesystemIterator::SKIP_DOTS)) as $file){
|
||||||
|
if (file_exists($file)) {
|
||||||
$size += $file->getSize();
|
$size += $file->getSize();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue