1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Slight improvement to File Inspector progress bar accuracy

The progress bar now counts upwards for all existing files rather than
the files known to be core.

Also fixed `error_log` name presented in
file_inspector::renderFileName()
This commit is contained in:
Nick Liu
2020-04-04 20:17:14 -05:00
parent 594f3b543c
commit fd7f0b178e

View File

@@ -368,8 +368,6 @@ class file_inspector {
$this->coreImage = e107::getFileInspector('core'); $this->coreImage = e107::getFileInspector('core');
$this->coreImageVersion = $this->coreImage->getCurrentVersion(); $this->coreImageVersion = $this->coreImage->getCurrentVersion();
$this->countFiles();
$this->root_dir = $e107 -> file_path; $this->root_dir = $e107 -> file_path;
if(substr($this->root_dir, -1) == '/') if(substr($this->root_dir, -1) == '/')
@@ -589,6 +587,10 @@ class file_inspector {
*/ */
protected function inspect($baseDir) protected function inspect($baseDir)
{ {
$this->progress_units = 0;
$this->totalFiles = 1;
$this->sendProgress(0);
$this->totalFiles = iterator_count(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($baseDir)));
$this->inspect_existing($baseDir); $this->inspect_existing($baseDir);
$this->inspect_missing(array_keys($this->files)); $this->inspect_missing(array_keys($this->files));
@@ -602,6 +604,7 @@ class file_inspector {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($baseDir)); $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($baseDir));
foreach ($iterator as $file) foreach ($iterator as $file)
{ {
$this->sendProgress(1);
if ($file->isDir()) continue; if ($file->isDir()) continue;
$absolutePath = $file->getRealPath(); $absolutePath = $file->getRealPath();
@@ -612,7 +615,6 @@ class file_inspector {
$this->files[$relativePath] = $this->coreImage->validate($relativePath); $this->files[$relativePath] = $this->coreImage->validate($relativePath);
$this->fileSizes[$relativePath] = filesize($absolutePath); $this->fileSizes[$relativePath] = filesize($absolutePath);
$this->updateFileSizeCounter($absolutePath, $this->files[$relativePath]); $this->updateFileSizeCounter($absolutePath, $this->files[$relativePath]);
$this->sendProgress(1);
} }
} }
@@ -687,7 +689,7 @@ class file_inspector {
e107::getSession()->set('fileinspector_error_log_'. $hash, $relativePath); e107::getSession()->set('fileinspector_error_log_'. $hash, $relativePath);
return "<a class='e-modal' data-modal-caption=\"".$relativePath."\" href='fileinspector.php?iframe=1&viewerror=".$hash."'>".$relativePath."</a>"; return "<a class='e-modal' data-modal-caption=\"".$relativePath."\" href='fileinspector.php?iframe=1&viewerror=".$hash."'>".$fileName."</a>";
} }
if (!is_array($tree[$fileName])) if (!is_array($tree[$fileName]))
@@ -1108,8 +1110,6 @@ class file_inspector {
$text .= "</table> $text .= "</table>
</div><br />"; </div><br />";
$this->sendProgress($this->totalFiles);
echo $text; echo $text;
self::pruneOldProgressFiles(); self::pruneOldProgressFiles();