3333use OCP \IConfig ;
3434use OCP \IDBConnection ;
3535use Symfony \Component \Console \Input \InputInterface ;
36- use Symfony \Component \Console \Input \InputOption ;
3736use Symfony \Component \Console \Output \OutputInterface ;
3837use Symfony \Component \Console \Helper \Table ;
3938
@@ -62,19 +61,7 @@ protected function configure() {
6261
6362 $ this
6463 ->setName ('files:scan-app-data ' )
65- ->setDescription ('rescan the AppData folder ' )
66- ->addOption (
67- 'quiet ' ,
68- 'q ' ,
69- InputOption::VALUE_NONE ,
70- 'suppress any output '
71- )
72- ->addOption (
73- 'verbose ' ,
74- '-v|vv|vvv ' ,
75- InputOption::VALUE_NONE ,
76- 'verbose the output '
77- );
64+ ->setDescription ('rescan the AppData folder ' );
7865 }
7966
8067 public function checkScanWarning ($ fullPath , OutputInterface $ output ) {
@@ -86,7 +73,7 @@ public function checkScanWarning($fullPath, OutputInterface $output) {
8673 }
8774 }
8875
89- protected function scanFiles ($ verbose , OutputInterface $ output ) {
76+ protected function scanFiles (OutputInterface $ output ) {
9077 try {
9178 $ appData = $ this ->getAppDataFolder ();
9279 } catch (NotFoundException $ e ) {
@@ -96,44 +83,36 @@ protected function scanFiles($verbose, OutputInterface $output) {
9683
9784 $ connection = $ this ->reconnectToDatabase ($ output );
9885 $ scanner = new \OC \Files \Utils \Scanner (null , $ connection , \OC ::$ server ->getLogger ());
86+
9987 # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
100- # printout and count
101- if ($ verbose ) {
102- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
103- $ output ->writeln ("\tFile <info> $ path</info> " );
104- $ this ->filesCounter += 1 ;
105- $ this ->abortIfInterrupted ();
106- });
107- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
108- $ output ->writeln ("\tFolder <info> $ path</info> " );
109- $ this ->foldersCounter += 1 ;
110- $ this ->abortIfInterrupted ();
111- });
112- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'StorageNotAvailable ' , function (StorageNotAvailableException $ e ) use ($ output ) {
113- $ output ->writeln ('Error while scanning, storage not available ( ' . $ e ->getMessage () . ') ' );
114- });
115- # count only
116- } else {
117- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function () use ($ output ) {
118- $ this ->filesCounter += 1 ;
119- $ this ->abortIfInterrupted ();
120- });
121- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function () use ($ output ) {
122- $ this ->foldersCounter += 1 ;
123- $ this ->abortIfInterrupted ();
124- });
125- }
126- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
88+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
89+ $ output ->writeln ("\tFile <info> $ path</info> " , OutputInterface::VERBOSITY_VERBOSE );
90+ ++$ this ->filesCounter ;
91+ $ this ->abortIfInterrupted ();
92+ });
93+
94+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
95+ $ output ->writeln ("\tFolder <info> $ path</info> " , OutputInterface::VERBOSITY_VERBOSE );
96+ ++$ this ->foldersCounter ;
97+ $ this ->abortIfInterrupted ();
98+ });
99+
100+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'StorageNotAvailable ' , function (StorageNotAvailableException $ e ) use ($ output ) {
101+ $ output ->writeln ('Error while scanning, storage not available ( ' . $ e ->getMessage () . ') ' , OutputInterface::VERBOSITY_VERBOSE );
102+ });
103+
104+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFile ' , function ($ path ) use ($ output ) {
127105 $ this ->checkScanWarning ($ path , $ output );
128106 });
129- $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
107+
108+ $ scanner ->listen ('\OC\Files\Utils\Scanner ' , 'scanFolder ' , function ($ path ) use ($ output ) {
130109 $ this ->checkScanWarning ($ path , $ output );
131110 });
132111
133112 try {
134113 $ scanner ->scan ($ appData ->getPath ());
135114 } catch (ForbiddenException $ e ) {
136- $ output ->writeln (" <error>Storage not writable</error> " );
115+ $ output ->writeln (' <error>Storage not writable</error> ' );
137116 $ output ->writeln ('Make sure you \'re running the scan command only as the user the web server runs as ' );
138117 } catch (InterruptedException $ e ) {
139118 # exit the function if ctrl-c has been pressed
@@ -148,33 +127,18 @@ protected function scanFiles($verbose, OutputInterface $output) {
148127
149128
150129 protected function execute (InputInterface $ input , OutputInterface $ output ) {
151- # no messaging level option means: no full printout but statistics
152- # $quiet means no print at all
153- # $verbose means full printout including statistics
154- # -q -v full stat
155- # 0 0 no yes
156- # 0 1 yes yes
157- # 1 -- no no (quiet overrules verbose)
158- $ verbose = $ input ->getOption ('verbose ' );
159- $ quiet = $ input ->getOption ('quiet ' );
160130 # restrict the verbosity level to VERBOSITY_VERBOSE
161131 if ($ output ->getVerbosity () > OutputInterface::VERBOSITY_VERBOSE ) {
162132 $ output ->setVerbosity (OutputInterface::VERBOSITY_VERBOSE );
163133 }
164- if ($ quiet ) {
165- $ verbose = false ;
166- }
167134
168135 $ output ->writeln ("\nScanning AppData for files " );
169136
170137 $ this ->initTools ();
171138
172- $ this ->scanFiles ($ verbose , $ output );
139+ $ this ->scanFiles ($ output );
173140
174- # stat: printout statistics if $quiet was not set
175- if (!$ quiet ) {
176- $ this ->presentStats ($ output );
177- }
141+ $ this ->presentStats ($ output );
178142 }
179143
180144 /**
0 commit comments