1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Another improvement to File Inspector progress bar accuracy

The progress bar now takes into account the time it takes to generate
the results HTML.  The first half of the progress bar is for the actual
file scanning, and the second half is reserved for generating the
results HTML.
This commit is contained in:
Nick Liu 2020-04-04 20:52:01 -05:00
parent fd7f0b178e
commit c8f6c49720
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637

View File

@ -590,7 +590,7 @@ class file_inspector {
$this->progress_units = 0;
$this->totalFiles = 1;
$this->sendProgress(0);
$this->totalFiles = iterator_count(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($baseDir)));
$this->totalFiles = iterator_count(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($baseDir))) * 2;
$this->inspect_existing($baseDir);
$this->inspect_missing(array_keys($this->files));
@ -709,6 +709,7 @@ class file_inspector {
$hide = $level;
foreach ($tree as $fileName => $validationCode)
{
$this->sendProgress(1);
$relativePath = ltrim("$parentPath/$fileName", '/');
if ($level === 0) $relativePath = '';
$rowId = str_replace(" ", "%20", $relativePath);
@ -951,16 +952,13 @@ class file_inspector {
'size' => 0,
]
];
$this->sendProgress(0);
$this->inspect($this->root_dir);
array_walk_recursive($this->files, function ($validationCode)
{
$status = $this->getStatusForValidationCode($validationCode);
$category = $this->statusToLegacyCountCategory($status);
$this->count[$category]['num']++;
$this->totalFiles++;
if ($validationCode & e_file_inspector::VALIDATED_PATH_VERSION &&
$validationCode & e_file_inspector::VALIDATED_FILE_EXISTS)
$this->count['core']['num']++;
@ -1112,6 +1110,7 @@ class file_inspector {
echo $text;
$this->sendProgress($this->totalFiles);
self::pruneOldProgressFiles();
}
@ -1167,11 +1166,6 @@ class file_inspector {
$inc = 100;
}
if (($inc > 5) && $inc % 5 !== 0)
{
return null;
}
if( $this->progressPercentage === $inc)
{
return null;