aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-06-16 17:56:34 +0200
committerRobin Appelman <robin@icewind.nl>2023-06-16 17:56:34 +0200
commit292c0e53f8acf1f235ae3a1e7c7674381eba8cb0 (patch)
tree29b9573b8efe3a2d84fe20be2361dd86509a5a52 /apps/files
parentb288d27c51187535bf11b7edc380f206f3d8392c (diff)
downloadnextcloud-server-292c0e53f8acf1f235ae3a1e7c7674381eba8cb0.tar.gz
nextcloud-server-292c0e53f8acf1f235ae3a1e7c7674381eba8cb0.zip
add summary of detected changes to files:scan output
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/Command/Scan.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index 6c7a607d2af..5d533899942 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;
@@ -59,18 +62,27 @@ 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;
private IRootFolder $root;
private MetadataManager $metadataManager;
+ private IEventDispatcher $eventDispatcher;
+ private LoggerInterface $logger;
public function __construct(
IUserManager $userManager,
IRootFolder $rootFolder,
- MetadataManager $metadataManager
+ MetadataManager $metadataManager,
+ IEventDispatcher $eventDispatcher,
+ LoggerInterface $logger
) {
$this->userManager = $userManager;
parent::__construct();
$this->root = $rootFolder;
$this->metadataManager = $metadataManager;
+ $this->eventDispatcher = $eventDispatcher;
+ $this->logger = $logger;
}
protected function configure() {
@@ -157,6 +169,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);
@@ -277,9 +299,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',
];
@@ -287,6 +314,9 @@ class Scan extends Base {
$rows = [
$this->foldersCounter,
$this->filesCounter,
+ $this->newCounter,
+ $this->updatedCounter,
+ $this->removedCounter,
$this->errorsCounter,
$niceDate,
];