|
12 | 12 |
|
13 | 13 | namespace marcocesarato\amwscan;
|
14 | 14 |
|
| 15 | +use ArrayIterator; |
15 | 16 | use CallbackFilterIterator;
|
16 | 17 | use Exception;
|
17 | 18 | use LimitIterator;
|
@@ -273,8 +274,7 @@ public function run($args = null)
|
273 | 274 | Console::writeLine('Scanning ' . self::$pathScan, 2);
|
274 | 275 |
|
275 | 276 | // 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); |
278 | 278 | $iterator = $this->mapping();
|
279 | 279 |
|
280 | 280 | // Counting files
|
@@ -674,7 +674,7 @@ private function modes()
|
674 | 674 | /**
|
675 | 675 | * Map files.
|
676 | 676 | *
|
677 |
| - * @return CallbackFilterIterator |
| 677 | + * @return ArrayIterator |
678 | 678 | */
|
679 | 679 | public function mapping()
|
680 | 680 | {
|
@@ -714,11 +714,26 @@ public function mapping()
|
714 | 714 | in_array($cur->getExtension(), self::getExtensions(), true);
|
715 | 715 | });
|
716 | 716 |
|
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); |
720 | 735 |
|
721 |
| - return $iterator; |
| 736 | + return $iterator->getIterator(); |
722 | 737 | }
|
723 | 738 |
|
724 | 739 | /**
|
|
0 commit comments