Skip to content

Commit 702ba1d

Browse files
committed
feat: add verifying status progress bar
1 parent 87ce9d8 commit 702ba1d

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/Scanner.php

+22-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace marcocesarato\amwscan;
1414

15+
use ArrayIterator;
1516
use CallbackFilterIterator;
1617
use Exception;
1718
use LimitIterator;
@@ -273,8 +274,7 @@ public function run($args = null)
273274
Console::writeLine('Scanning ' . self::$pathScan, 2);
274275

275276
// Mapping files
276-
Console::writeLine('Mapping, retrieving checksums and verifying files');
277-
Console::displayLine('It may take a while, please wait...');
277+
Console::writeLine('Mapping and retrieving checksums, please wait...', 2);
278278
$iterator = $this->mapping();
279279

280280
// Counting files
@@ -674,7 +674,7 @@ private function modes()
674674
/**
675675
* Map files.
676676
*
677-
* @return CallbackFilterIterator
677+
* @return ArrayIterator
678678
*/
679679
public function mapping()
680680
{
@@ -714,11 +714,26 @@ public function mapping()
714714
in_array($cur->getExtension(), self::getExtensions(), true);
715715
});
716716

717-
$iterator = new CallbackFilterIterator($filtered, function ($cur) {
718-
return $cur->isFile() && !Modules::isVerified($cur->getPathname());
719-
});
717+
$mapping = array();
718+
719+
$mapped = 0;
720+
$count = iterator_count($filtered);
721+
722+
Console::writeBreak(1);
723+
Console::writeLine('Verifying files checksum...', 2);
724+
725+
foreach ($filtered as $cur) {
726+
Console::progress($mapped++, $count);
727+
if ($cur->isFile() && !Modules::isVerified($cur->getPathname())) {
728+
$mapping[] = $cur;
729+
}
730+
Console::progress($mapped, $count);
731+
}
732+
$iterator = new \ArrayObject($mapping);
733+
734+
Console::writeBreak(1);
720735

721-
return $iterator;
736+
return $iterator->getIterator();
722737
}
723738

724739
/**

0 commit comments

Comments
 (0)