Completed
Pull Request — master (#3952)
by Lukas
320:57 queued 308:27
created
apps/files/lib/Command/Scan.php 2 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -43,306 +43,306 @@
 block discarded – undo
43 43
 
44 44
 class Scan extends Base {
45 45
 
46
-	/** @var IUserManager $userManager */
47
-	private $userManager;
48
-	/** @var float */
49
-	protected $execTime = 0;
50
-	/** @var int */
51
-	protected $foldersCounter = 0;
52
-	/** @var int */
53
-	protected $filesCounter = 0;
46
+    /** @var IUserManager $userManager */
47
+    private $userManager;
48
+    /** @var float */
49
+    protected $execTime = 0;
50
+    /** @var int */
51
+    protected $foldersCounter = 0;
52
+    /** @var int */
53
+    protected $filesCounter = 0;
54 54
 
55
-	public function __construct(IUserManager $userManager) {
56
-		$this->userManager = $userManager;
57
-		parent::__construct();
58
-	}
55
+    public function __construct(IUserManager $userManager) {
56
+        $this->userManager = $userManager;
57
+        parent::__construct();
58
+    }
59 59
 
60
-	protected function configure() {
61
-		parent::configure();
60
+    protected function configure() {
61
+        parent::configure();
62 62
 
63
-		$this
64
-			->setName('files:scan')
65
-			->setDescription('rescan filesystem')
66
-			->addArgument(
67
-				'user_id',
68
-				InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
69
-				'will rescan all files of the given user(s)'
70
-			)
71
-			->addOption(
72
-				'path',
73
-				'p',
74
-				InputArgument::OPTIONAL,
75
-				'limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored'
76
-			)
77
-			->addOption(
78
-				'quiet',
79
-				'q',
80
-				InputOption::VALUE_NONE,
81
-				'suppress any output'
82
-			)
83
-			->addOption(
84
-				'verbose',
85
-				'-v|vv|vvv',
86
-				InputOption::VALUE_NONE,
87
-				'verbose the output'
88
-			)
89
-			->addOption(
90
-				'all',
91
-				null,
92
-				InputOption::VALUE_NONE,
93
-				'will rescan all files of all known users'
94
-			)->addOption(
95
-				'unscanned',
96
-				null,
97
-				InputOption::VALUE_NONE,
98
-				'only scan files which are marked as not fully scanned'
99
-			);
100
-	}
63
+        $this
64
+            ->setName('files:scan')
65
+            ->setDescription('rescan filesystem')
66
+            ->addArgument(
67
+                'user_id',
68
+                InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
69
+                'will rescan all files of the given user(s)'
70
+            )
71
+            ->addOption(
72
+                'path',
73
+                'p',
74
+                InputArgument::OPTIONAL,
75
+                'limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored'
76
+            )
77
+            ->addOption(
78
+                'quiet',
79
+                'q',
80
+                InputOption::VALUE_NONE,
81
+                'suppress any output'
82
+            )
83
+            ->addOption(
84
+                'verbose',
85
+                '-v|vv|vvv',
86
+                InputOption::VALUE_NONE,
87
+                'verbose the output'
88
+            )
89
+            ->addOption(
90
+                'all',
91
+                null,
92
+                InputOption::VALUE_NONE,
93
+                'will rescan all files of all known users'
94
+            )->addOption(
95
+                'unscanned',
96
+                null,
97
+                InputOption::VALUE_NONE,
98
+                'only scan files which are marked as not fully scanned'
99
+            );
100
+    }
101 101
 
102
-	public function checkScanWarning($fullPath, OutputInterface $output) {
103
-		$normalizedPath = basename(\OC\Files\Filesystem::normalizePath($fullPath));
104
-		$path = basename($fullPath);
102
+    public function checkScanWarning($fullPath, OutputInterface $output) {
103
+        $normalizedPath = basename(\OC\Files\Filesystem::normalizePath($fullPath));
104
+        $path = basename($fullPath);
105 105
 
106
-		if ($normalizedPath !== $path) {
107
-			$output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
108
-		}
109
-	}
106
+        if ($normalizedPath !== $path) {
107
+            $output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
108
+        }
109
+    }
110 110
 
111
-	protected function scanFiles($user, $path, $verbose, OutputInterface $output, $backgroundScan = false) {
112
-		$connection = $this->reconnectToDatabase($output);
113
-		$scanner = new \OC\Files\Utils\Scanner($user, $connection, \OC::$server->getLogger());
114
-		# check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
115
-		# printout and count
116
-		if ($verbose) {
117
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
118
-				$output->writeln("\tFile   <info>$path</info>");
119
-				$this->filesCounter += 1;
120
-				if ($this->hasBeenInterrupted()) {
121
-					throw new InterruptedException();
122
-				}
123
-			});
124
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
125
-				$output->writeln("\tFolder <info>$path</info>");
126
-				$this->foldersCounter += 1;
127
-				if ($this->hasBeenInterrupted()) {
128
-					throw new InterruptedException();
129
-				}
130
-			});
131
-			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
132
-				$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
133
-			});
134
-		# count only
135
-		} else {
136
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
137
-				$this->filesCounter += 1;
138
-				if ($this->hasBeenInterrupted()) {
139
-					throw new InterruptedException();
140
-				}
141
-			});
142
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
143
-				$this->foldersCounter += 1;
144
-				if ($this->hasBeenInterrupted()) {
145
-					throw new InterruptedException();
146
-				}
147
-			});
148
-		}
149
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
150
-			$this->checkScanWarning($path, $output);
151
-		});
152
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) {
153
-			$this->checkScanWarning($path, $output);
154
-		});
111
+    protected function scanFiles($user, $path, $verbose, OutputInterface $output, $backgroundScan = false) {
112
+        $connection = $this->reconnectToDatabase($output);
113
+        $scanner = new \OC\Files\Utils\Scanner($user, $connection, \OC::$server->getLogger());
114
+        # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
115
+        # printout and count
116
+        if ($verbose) {
117
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
118
+                $output->writeln("\tFile   <info>$path</info>");
119
+                $this->filesCounter += 1;
120
+                if ($this->hasBeenInterrupted()) {
121
+                    throw new InterruptedException();
122
+                }
123
+            });
124
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
125
+                $output->writeln("\tFolder <info>$path</info>");
126
+                $this->foldersCounter += 1;
127
+                if ($this->hasBeenInterrupted()) {
128
+                    throw new InterruptedException();
129
+                }
130
+            });
131
+            $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
132
+                $output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
133
+            });
134
+        # count only
135
+        } else {
136
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
137
+                $this->filesCounter += 1;
138
+                if ($this->hasBeenInterrupted()) {
139
+                    throw new InterruptedException();
140
+                }
141
+            });
142
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
143
+                $this->foldersCounter += 1;
144
+                if ($this->hasBeenInterrupted()) {
145
+                    throw new InterruptedException();
146
+                }
147
+            });
148
+        }
149
+        $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
150
+            $this->checkScanWarning($path, $output);
151
+        });
152
+        $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) {
153
+            $this->checkScanWarning($path, $output);
154
+        });
155 155
 
156
-		try {
157
-			if ($backgroundScan) {
158
-				$scanner->backgroundScan($path);
159
-			}else {
160
-				$scanner->scan($path);
161
-			}
162
-		} catch (ForbiddenException $e) {
163
-			$output->writeln("<error>Home storage for user $user not writable</error>");
164
-			$output->writeln("Make sure you're running the scan command only as the user the web server runs as");
165
-		} catch (InterruptedException $e) {
166
-			# exit the function if ctrl-c has been pressed
167
-			$output->writeln('Interrupted by user');
168
-		} catch (\Exception $e) {
169
-			$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
170
-			$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
171
-		}
172
-	}
156
+        try {
157
+            if ($backgroundScan) {
158
+                $scanner->backgroundScan($path);
159
+            }else {
160
+                $scanner->scan($path);
161
+            }
162
+        } catch (ForbiddenException $e) {
163
+            $output->writeln("<error>Home storage for user $user not writable</error>");
164
+            $output->writeln("Make sure you're running the scan command only as the user the web server runs as");
165
+        } catch (InterruptedException $e) {
166
+            # exit the function if ctrl-c has been pressed
167
+            $output->writeln('Interrupted by user');
168
+        } catch (\Exception $e) {
169
+            $output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
170
+            $output->writeln('<error>' . $e->getTraceAsString() . '</error>');
171
+        }
172
+    }
173 173
 
174 174
 
175
-	protected function execute(InputInterface $input, OutputInterface $output) {
176
-		$inputPath = $input->getOption('path');
177
-		if ($inputPath) {
178
-			$inputPath = '/' . trim($inputPath, '/');
179
-			list (, $user,) = explode('/', $inputPath, 3);
180
-			$users = array($user);
181
-		} else if ($input->getOption('all')) {
182
-			$users = $this->userManager->search('');
183
-		} else {
184
-			$users = $input->getArgument('user_id');
185
-		}
175
+    protected function execute(InputInterface $input, OutputInterface $output) {
176
+        $inputPath = $input->getOption('path');
177
+        if ($inputPath) {
178
+            $inputPath = '/' . trim($inputPath, '/');
179
+            list (, $user,) = explode('/', $inputPath, 3);
180
+            $users = array($user);
181
+        } else if ($input->getOption('all')) {
182
+            $users = $this->userManager->search('');
183
+        } else {
184
+            $users = $input->getArgument('user_id');
185
+        }
186 186
 
187
-		# no messaging level option means: no full printout but statistics
188
-		# $quiet   means no print at all
189
-		# $verbose means full printout including statistics
190
-		# -q	-v	full	stat
191
-		#  0	 0	no	yes
192
-		#  0	 1	yes	yes
193
-		#  1	--	no	no  (quiet overrules verbose)
194
-		$verbose = $input->getOption('verbose');
195
-		$quiet = $input->getOption('quiet');
196
-		# restrict the verbosity level to VERBOSITY_VERBOSE
197
-		if ($output->getVerbosity()>OutputInterface::VERBOSITY_VERBOSE) {
198
-			$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
199
-		}
200
-		if ($quiet) {
201
-			$verbose = false;
202
-		}
187
+        # no messaging level option means: no full printout but statistics
188
+        # $quiet   means no print at all
189
+        # $verbose means full printout including statistics
190
+        # -q	-v	full	stat
191
+        #  0	 0	no	yes
192
+        #  0	 1	yes	yes
193
+        #  1	--	no	no  (quiet overrules verbose)
194
+        $verbose = $input->getOption('verbose');
195
+        $quiet = $input->getOption('quiet');
196
+        # restrict the verbosity level to VERBOSITY_VERBOSE
197
+        if ($output->getVerbosity()>OutputInterface::VERBOSITY_VERBOSE) {
198
+            $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
199
+        }
200
+        if ($quiet) {
201
+            $verbose = false;
202
+        }
203 203
 
204
-		# check quantity of users to be process and show it on the command line
205
-		$users_total = count($users);
206
-		if ($users_total === 0) {
207
-			$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
208
-			return;
209
-		} else {
210
-			if ($users_total > 1) {
211
-				$output->writeln("\nScanning files for $users_total users");
212
-			}
213
-		}
204
+        # check quantity of users to be process and show it on the command line
205
+        $users_total = count($users);
206
+        if ($users_total === 0) {
207
+            $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
208
+            return;
209
+        } else {
210
+            if ($users_total > 1) {
211
+                $output->writeln("\nScanning files for $users_total users");
212
+            }
213
+        }
214 214
 
215
-		$this->initTools();
215
+        $this->initTools();
216 216
 
217
-		$user_count = 0;
218
-		foreach ($users as $user) {
219
-			if (is_object($user)) {
220
-				$user = $user->getUID();
221
-			}
222
-			$path = $inputPath ? $inputPath : '/' . $user;
223
-			$user_count += 1;
224
-			if ($this->userManager->userExists($user)) {
225
-				# add an extra line when verbose is set to optical separate users
226
-				if ($verbose) {$output->writeln(""); }
227
-				$output->writeln("Starting scan for user $user_count out of $users_total ($user)");
228
-				# full: printout data if $verbose was set
229
-				$this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'));
230
-			} else {
231
-				$output->writeln("<error>Unknown user $user_count $user</error>");
232
-			}
233
-			# check on each user if there was a user interrupt (ctrl-c) and exit foreach
234
-			if ($this->hasBeenInterrupted()) {
235
-				break;
236
-			}
237
-		}
217
+        $user_count = 0;
218
+        foreach ($users as $user) {
219
+            if (is_object($user)) {
220
+                $user = $user->getUID();
221
+            }
222
+            $path = $inputPath ? $inputPath : '/' . $user;
223
+            $user_count += 1;
224
+            if ($this->userManager->userExists($user)) {
225
+                # add an extra line when verbose is set to optical separate users
226
+                if ($verbose) {$output->writeln(""); }
227
+                $output->writeln("Starting scan for user $user_count out of $users_total ($user)");
228
+                # full: printout data if $verbose was set
229
+                $this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'));
230
+            } else {
231
+                $output->writeln("<error>Unknown user $user_count $user</error>");
232
+            }
233
+            # check on each user if there was a user interrupt (ctrl-c) and exit foreach
234
+            if ($this->hasBeenInterrupted()) {
235
+                break;
236
+            }
237
+        }
238 238
 
239
-		# stat: printout statistics if $quiet was not set
240
-		if (!$quiet) {
241
-			$this->presentStats($output);
242
-		}
243
-	}
239
+        # stat: printout statistics if $quiet was not set
240
+        if (!$quiet) {
241
+            $this->presentStats($output);
242
+        }
243
+    }
244 244
 
245
-	/**
246
-	 * Initialises some useful tools for the Command
247
-	 */
248
-	protected function initTools() {
249
-		// Start the timer
250
-		$this->execTime = -microtime(true);
251
-		// Convert PHP errors to exceptions
252
-		set_error_handler([$this, 'exceptionErrorHandler'], E_ALL);
253
-	}
245
+    /**
246
+     * Initialises some useful tools for the Command
247
+     */
248
+    protected function initTools() {
249
+        // Start the timer
250
+        $this->execTime = -microtime(true);
251
+        // Convert PHP errors to exceptions
252
+        set_error_handler([$this, 'exceptionErrorHandler'], E_ALL);
253
+    }
254 254
 
255
-	/**
256
-	 * Processes PHP errors as exceptions in order to be able to keep track of problems
257
-	 *
258
-	 * @see https://secure.php.net/manual/en/function.set-error-handler.php
259
-	 *
260
-	 * @param int $severity the level of the error raised
261
-	 * @param string $message
262
-	 * @param string $file the filename that the error was raised in
263
-	 * @param int $line the line number the error was raised
264
-	 *
265
-	 * @throws \ErrorException
266
-	 */
267
-	public function exceptionErrorHandler($severity, $message, $file, $line) {
268
-		if (!(error_reporting() & $severity)) {
269
-			// This error code is not included in error_reporting
270
-			return;
271
-		}
272
-		throw new \ErrorException($message, 0, $severity, $file, $line);
273
-	}
255
+    /**
256
+     * Processes PHP errors as exceptions in order to be able to keep track of problems
257
+     *
258
+     * @see https://secure.php.net/manual/en/function.set-error-handler.php
259
+     *
260
+     * @param int $severity the level of the error raised
261
+     * @param string $message
262
+     * @param string $file the filename that the error was raised in
263
+     * @param int $line the line number the error was raised
264
+     *
265
+     * @throws \ErrorException
266
+     */
267
+    public function exceptionErrorHandler($severity, $message, $file, $line) {
268
+        if (!(error_reporting() & $severity)) {
269
+            // This error code is not included in error_reporting
270
+            return;
271
+        }
272
+        throw new \ErrorException($message, 0, $severity, $file, $line);
273
+    }
274 274
 
275
-	/**
276
-	 * @param OutputInterface $output
277
-	 */
278
-	protected function presentStats(OutputInterface $output) {
279
-		// Stop the timer
280
-		$this->execTime += microtime(true);
281
-		$output->writeln("");
275
+    /**
276
+     * @param OutputInterface $output
277
+     */
278
+    protected function presentStats(OutputInterface $output) {
279
+        // Stop the timer
280
+        $this->execTime += microtime(true);
281
+        $output->writeln("");
282 282
 
283
-		$headers = [
284
-			'Folders', 'Files', 'Elapsed time'
285
-		];
283
+        $headers = [
284
+            'Folders', 'Files', 'Elapsed time'
285
+        ];
286 286
 
287
-		$this->showSummary($headers, null, $output);
288
-	}
287
+        $this->showSummary($headers, null, $output);
288
+    }
289 289
 
290
-	/**
291
-	 * Shows a summary of operations
292
-	 *
293
-	 * @param string[] $headers
294
-	 * @param string[] $rows
295
-	 * @param OutputInterface $output
296
-	 */
297
-	protected function showSummary($headers, $rows, OutputInterface $output) {
298
-		$niceDate = $this->formatExecTime();
299
-		if (!$rows) {
300
-			$rows = [
301
-				$this->foldersCounter,
302
-				$this->filesCounter,
303
-				$niceDate,
304
-			];
305
-		}
306
-		$table = new Table($output);
307
-		$table
308
-			->setHeaders($headers)
309
-			->setRows([$rows]);
310
-		$table->render();
311
-	}
290
+    /**
291
+     * Shows a summary of operations
292
+     *
293
+     * @param string[] $headers
294
+     * @param string[] $rows
295
+     * @param OutputInterface $output
296
+     */
297
+    protected function showSummary($headers, $rows, OutputInterface $output) {
298
+        $niceDate = $this->formatExecTime();
299
+        if (!$rows) {
300
+            $rows = [
301
+                $this->foldersCounter,
302
+                $this->filesCounter,
303
+                $niceDate,
304
+            ];
305
+        }
306
+        $table = new Table($output);
307
+        $table
308
+            ->setHeaders($headers)
309
+            ->setRows([$rows]);
310
+        $table->render();
311
+    }
312 312
 
313 313
 
314
-	/**
315
-	 * Formats microtime into a human readable format
316
-	 *
317
-	 * @return string
318
-	 */
319
-	protected function formatExecTime() {
320
-		list($secs, $tens) = explode('.', sprintf("%.1f", ($this->execTime)));
314
+    /**
315
+     * Formats microtime into a human readable format
316
+     *
317
+     * @return string
318
+     */
319
+    protected function formatExecTime() {
320
+        list($secs, $tens) = explode('.', sprintf("%.1f", ($this->execTime)));
321 321
 
322
-		# if you want to have microseconds add this:   . '.' . $tens;
323
-		return date('H:i:s', $secs);
324
-	}
322
+        # if you want to have microseconds add this:   . '.' . $tens;
323
+        return date('H:i:s', $secs);
324
+    }
325 325
 
326
-	/**
327
-	 * @return \OCP\IDBConnection
328
-	 */
329
-	protected function reconnectToDatabase(OutputInterface $output) {
330
-		/** @var Connection | IDBConnection $connection*/
331
-		$connection = \OC::$server->getDatabaseConnection();
332
-		try {
333
-			$connection->close();
334
-		} catch (\Exception $ex) {
335
-			$output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
336
-		}
337
-		while (!$connection->isConnected()) {
338
-			try {
339
-				$connection->connect();
340
-			} catch (\Exception $ex) {
341
-				$output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
342
-				sleep(60);
343
-			}
344
-		}
345
-		return $connection;
346
-	}
326
+    /**
327
+     * @return \OCP\IDBConnection
328
+     */
329
+    protected function reconnectToDatabase(OutputInterface $output) {
330
+        /** @var Connection | IDBConnection $connection*/
331
+        $connection = \OC::$server->getDatabaseConnection();
332
+        try {
333
+            $connection->close();
334
+        } catch (\Exception $ex) {
335
+            $output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
336
+        }
337
+        while (!$connection->isConnected()) {
338
+            try {
339
+                $connection->connect();
340
+            } catch (\Exception $ex) {
341
+                $output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
342
+                sleep(60);
343
+            }
344
+        }
345
+        return $connection;
346
+    }
347 347
 
348 348
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		$path = basename($fullPath);
105 105
 
106 106
 		if ($normalizedPath !== $path) {
107
-			$output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
107
+			$output->writeln("\t<error>Entry \"".$fullPath.'" will not be accessible due to incompatible encoding</error>');
108 108
 		}
109 109
 	}
110 110
 
@@ -114,32 +114,32 @@  discard block
 block discarded – undo
114 114
 		# check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
115 115
 		# printout and count
116 116
 		if ($verbose) {
117
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
117
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
118 118
 				$output->writeln("\tFile   <info>$path</info>");
119 119
 				$this->filesCounter += 1;
120 120
 				if ($this->hasBeenInterrupted()) {
121 121
 					throw new InterruptedException();
122 122
 				}
123 123
 			});
124
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
124
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) {
125 125
 				$output->writeln("\tFolder <info>$path</info>");
126 126
 				$this->foldersCounter += 1;
127 127
 				if ($this->hasBeenInterrupted()) {
128 128
 					throw new InterruptedException();
129 129
 				}
130 130
 			});
131
-			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
132
-				$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
131
+			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function(StorageNotAvailableException $e) use ($output) {
132
+				$output->writeln("Error while scanning, storage not available (".$e->getMessage().")");
133 133
 			});
134 134
 		# count only
135 135
 		} else {
136
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
136
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function() use ($output) {
137 137
 				$this->filesCounter += 1;
138 138
 				if ($this->hasBeenInterrupted()) {
139 139
 					throw new InterruptedException();
140 140
 				}
141 141
 			});
142
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
142
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function() use ($output) {
143 143
 				$this->foldersCounter += 1;
144 144
 				if ($this->hasBeenInterrupted()) {
145 145
 					throw new InterruptedException();
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		try {
157 157
 			if ($backgroundScan) {
158 158
 				$scanner->backgroundScan($path);
159
-			}else {
159
+			} else {
160 160
 				$scanner->scan($path);
161 161
 			}
162 162
 		} catch (ForbiddenException $e) {
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 			# exit the function if ctrl-c has been pressed
167 167
 			$output->writeln('Interrupted by user');
168 168
 		} catch (\Exception $e) {
169
-			$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
170
-			$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
169
+			$output->writeln('<error>Exception during scan: '.$e->getMessage().'</error>');
170
+			$output->writeln('<error>'.$e->getTraceAsString().'</error>');
171 171
 		}
172 172
 	}
173 173
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	protected function execute(InputInterface $input, OutputInterface $output) {
176 176
 		$inputPath = $input->getOption('path');
177 177
 		if ($inputPath) {
178
-			$inputPath = '/' . trim($inputPath, '/');
178
+			$inputPath = '/'.trim($inputPath, '/');
179 179
 			list (, $user,) = explode('/', $inputPath, 3);
180 180
 			$users = array($user);
181 181
 		} else if ($input->getOption('all')) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$verbose = $input->getOption('verbose');
195 195
 		$quiet = $input->getOption('quiet');
196 196
 		# restrict the verbosity level to VERBOSITY_VERBOSE
197
-		if ($output->getVerbosity()>OutputInterface::VERBOSITY_VERBOSE) {
197
+		if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
198 198
 			$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
199 199
 		}
200 200
 		if ($quiet) {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			if (is_object($user)) {
220 220
 				$user = $user->getUID();
221 221
 			}
222
-			$path = $inputPath ? $inputPath : '/' . $user;
222
+			$path = $inputPath ? $inputPath : '/'.$user;
223 223
 			$user_count += 1;
224 224
 			if ($this->userManager->userExists($user)) {
225 225
 				# add an extra line when verbose is set to optical separate users
Please login to merge, or discard this patch.