3232use OC \Core \Command \Base ;
3333use OC \Core \Command \InterruptedException ;
3434use OC \ForbiddenException ;
35+ use OCP \Files \NotFoundException ;
3536use OCP \Files \StorageNotAvailableException ;
3637use OCP \IDBConnection ;
3738use OCP \IUserManager ;
@@ -131,7 +132,7 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output, $b
131132 $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'StorageNotAvailable ' , function (StorageNotAvailableException $ e ) use ($ output ) {
132133 $ output ->writeln ("Error while scanning, storage not available ( " . $ e ->getMessage () . ") " );
133134 });
134- # count only
135+ # count only
135136 } else {
136137 $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function () use ($ output ) {
137138 $ this ->filesCounter += 1 ;
@@ -146,17 +147,17 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output, $b
146147 }
147148 });
148149 }
149- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
150+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
150151 $ this ->checkScanWarning ($ path , $ output );
151152 });
152- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
153+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
153154 $ this ->checkScanWarning ($ path , $ output );
154155 });
155156
156157 try {
157158 if ($ backgroundScan ) {
158159 $ scanner ->backgroundScan ($ path );
159- }else {
160+ } else {
160161 $ scanner ->scan ($ path );
161162 }
162163 } catch (ForbiddenException $ e ) {
@@ -165,6 +166,8 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output, $b
165166 } catch (InterruptedException $ e ) {
166167 # exit the function if ctrl-c has been pressed
167168 $ output ->writeln ('Interrupted by user ' );
169+ } catch (NotFoundException $ e ) {
170+ $ output ->writeln ('<error>Path not found: ' . $ e ->getMessage () . '</error> ' );
168171 } catch (\Exception $ e ) {
169172 $ output ->writeln ('<error>Exception during scan: ' . $ e ->getMessage () . '</error> ' );
170173 $ output ->writeln ('<error> ' . $ e ->getTraceAsString () . '</error> ' );
@@ -194,7 +197,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
194197 $ verbose = $ input ->getOption ('verbose ' );
195198 $ quiet = $ input ->getOption ('quiet ' );
196199 # restrict the verbosity level to VERBOSITY_VERBOSE
197- if ($ output ->getVerbosity ()> OutputInterface::VERBOSITY_VERBOSE ) {
200+ if ($ output ->getVerbosity () > OutputInterface::VERBOSITY_VERBOSE ) {
198201 $ output ->setVerbosity (OutputInterface::VERBOSITY_VERBOSE );
199202 }
200203 if ($ quiet ) {
@@ -223,7 +226,9 @@ protected function execute(InputInterface $input, OutputInterface $output) {
223226 $ user_count += 1 ;
224227 if ($ this ->userManager ->userExists ($ user )) {
225228 # add an extra line when verbose is set to optical separate users
226- if ($ verbose ) {$ output ->writeln ("" ); }
229+ if ($ verbose ) {
230+ $ output ->writeln ("" );
231+ }
227232 $ output ->writeln ("Starting scan for user $ user_count out of $ users_total ( $ user) " );
228233 # full: printout data if $verbose was set
229234 $ this ->scanFiles ($ user , $ path , $ verbose , $ output , $ input ->getOption ('unscanned ' ));
@@ -327,7 +332,7 @@ protected function formatExecTime() {
327332 * @return \OCP\IDBConnection
328333 */
329334 protected function reconnectToDatabase (OutputInterface $ output ) {
330- /** @var Connection | IDBConnection $connection*/
335+ /** @var Connection | IDBConnection $connection */
331336 $ connection = \OC ::$ server ->getDatabaseConnection ();
332337 try {
333338 $ connection ->close ();
0 commit comments