diff options
Diffstat (limited to 'apps/files/lib/Command/Scan.php')
-rw-r--r-- | apps/files/lib/Command/Scan.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 8c3574d7608..f5ac3627196 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -37,6 +37,9 @@ use OC\Core\Command\Base; use OC\Core\Command\InterruptedException; use OC\DB\Connection; use OC\DB\ConnectionAdapter; +use OCP\Files\Events\FileCacheUpdated; +use OCP\Files\Events\NodeAddedToCache; +use OCP\Files\Events\NodeRemovedFromCache; use OCP\Files\File; use OC\ForbiddenException; use OC\Metadata\MetadataManager; @@ -58,11 +61,16 @@ class Scan extends Base { protected int $foldersCounter = 0; protected int $filesCounter = 0; protected int $errorsCounter = 0; + protected int $newCounter = 0; + protected int $updatedCounter = 0; + protected int $removedCounter = 0; public function __construct( private IUserManager $userManager, private IRootFolder $rootFolder, - private MetadataManager $metadataManager + private MetadataManager $metadataManager, + private IEventDispatcher $eventDispatcher, + private LoggerInterface $logger, ) { parent::__construct(); } @@ -151,6 +159,16 @@ class Scan extends Base { ++$this->errorsCounter; }); + $this->eventDispatcher->addListener(NodeAddedToCache::class, function() { + ++$this->newCounter; + }); + $this->eventDispatcher->addListener(FileCacheUpdated::class, function() { + ++$this->updatedCounter; + }); + $this->eventDispatcher->addListener(NodeRemovedFromCache::class, function() { + ++$this->removedCounter; + }); + try { if ($backgroundScan) { $scanner->backgroundScan($path); @@ -268,9 +286,14 @@ class Scan extends Base { // Stop the timer $this->execTime += microtime(true); + $this->logger->info("Completed scan of {$this->filesCounter} files in {$this->foldersCounter} folder. Found {$this->newCounter} new, {$this->updatedCounter} updated and {$this->removedCounter} removed items"); + $headers = [ 'Folders', 'Files', + 'New', + 'Updated', + 'Removed', 'Errors', 'Elapsed time', ]; @@ -278,6 +301,9 @@ class Scan extends Base { $rows = [ $this->foldersCounter, $this->filesCounter, + $this->newCounter, + $this->updatedCounter, + $this->removedCounter, $this->errorsCounter, $niceDate, ]; |