Skip to content

Commit bd81216

Browse files
committed
occ scan:files Adding more details in the base print out (II)
1 parent d0a690f commit bd81216

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

apps/files/command/scan.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output) {
9696
# printout and count
9797
if ($verbose) {
9898
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
99-
$output->writeln("Scanning file <info>$path</info>");
99+
$output->writeln("\tFile <info>$path</info>");
100100
$this->filesCounter += 1;
101101
});
102102
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
103-
$output->writeln("Scanning folder <info>$path</info>");
103+
$output->writeln("\tFolder <info>$path</info>");
104104
$this->foldersCounter += 1;
105105
});
106106
$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
@@ -137,11 +137,6 @@ protected function execute(InputInterface $input, OutputInterface $output) {
137137
$users = $input->getArgument('user_id');
138138
}
139139

140-
if (count($users) === 0) {
141-
$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
142-
return;
143-
}
144-
145140
# no messaging level option means: no full printout but statistics
146141
# $quiet means no print at all
147142
# $verbose means full printout including statistics
@@ -159,18 +154,34 @@ protected function execute(InputInterface $input, OutputInterface $output) {
159154
$verbose = false;
160155
}
161156

157+
# check quantity of users to be process and show it on the command line
158+
$users_total = count($users);
159+
if ($users_total === 0) {
160+
$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
161+
return;
162+
} else {
163+
if ($users_total > 1) {
164+
$output->writeln("\nScanning files for $users_total users");
165+
}
166+
}
167+
162168
$this->initTools();
163169

170+
$user_count = 0;
164171
foreach ($users as $user) {
165172
if (is_object($user)) {
166173
$user = $user->getUID();
167174
}
168175
$path = $inputPath ? $inputPath : '/' . $user;
176+
$user_count += 1;
169177
if ($this->userManager->userExists($user)) {
178+
# add an extra line when verbose is set to optical seperate users
179+
if ($verbose) {$output->writeln(""); }
180+
$output->writeln("Starting scan for user $user_count out of $users_total ($user)");
170181
# full: printout data if $verbose was set
171182
$this->scanFiles($user, $path, $verbose, $output);
172183
} else {
173-
$output->writeln("<error>Unknown user $user</error>");
184+
$output->writeln("<error>Unknown user $user_count $user</error>");
174185
}
175186
}
176187

@@ -300,7 +311,8 @@ protected function showSummary($headers, $rows, OutputInterface $output) {
300311
*/
301312
protected function formatExecTime() {
302313
list($secs, $tens) = explode('.', sprintf("%.1f", ($this->execTime)));
303-
$niceDate = date('H:i:s', $secs) . '.' . $tens;
314+
# add the following to $niceDate if you want to have microsecons added: . '.' . $tens;
315+
$niceDate = date('H:i:s', $secs);
304316

305317
return $niceDate;
306318
}

0 commit comments

Comments
 (0)