Completed
Pull Request — master (#10038)
by Robin
24:44
created
lib/private/Files/Utils/Scanner.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@
 block discarded – undo
182 182
 
183 183
 	/**
184 184
 	 * @param string $dir
185
-	 * @param $recursive
185
+	 * @param boolean $recursive
186 186
 	 * @param callable|null $mountFilter
187 187
 	 * @throws ForbiddenException
188 188
 	 * @throws NotFoundException
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -50,238 +50,238 @@
 block discarded – undo
50 50
  * @package OC\Files\Utils
51 51
  */
52 52
 class Scanner extends PublicEmitter {
53
-	const MAX_ENTRIES_TO_COMMIT = 10000;
53
+    const MAX_ENTRIES_TO_COMMIT = 10000;
54 54
 
55
-	/**
56
-	 * @var string $user
57
-	 */
58
-	private $user;
55
+    /**
56
+     * @var string $user
57
+     */
58
+    private $user;
59 59
 
60
-	/**
61
-	 * @var \OCP\IDBConnection
62
-	 */
63
-	protected $db;
60
+    /**
61
+     * @var \OCP\IDBConnection
62
+     */
63
+    protected $db;
64 64
 
65
-	/**
66
-	 * @var ILogger
67
-	 */
68
-	protected $logger;
65
+    /**
66
+     * @var ILogger
67
+     */
68
+    protected $logger;
69 69
 
70
-	/**
71
-	 * Whether to use a DB transaction
72
-	 *
73
-	 * @var bool
74
-	 */
75
-	protected $useTransaction;
70
+    /**
71
+     * Whether to use a DB transaction
72
+     *
73
+     * @var bool
74
+     */
75
+    protected $useTransaction;
76 76
 
77
-	/**
78
-	 * Number of entries scanned to commit
79
-	 *
80
-	 * @var int
81
-	 */
82
-	protected $entriesToCommit;
77
+    /**
78
+     * Number of entries scanned to commit
79
+     *
80
+     * @var int
81
+     */
82
+    protected $entriesToCommit;
83 83
 
84
-	/**
85
-	 * @param string $user
86
-	 * @param \OCP\IDBConnection $db
87
-	 * @param ILogger $logger
88
-	 */
89
-	public function __construct($user, $db, ILogger $logger) {
90
-		$this->logger = $logger;
91
-		$this->user = $user;
92
-		$this->db = $db;
93
-		// when DB locking is used, no DB transactions will be used
94
-		$this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider);
95
-	}
84
+    /**
85
+     * @param string $user
86
+     * @param \OCP\IDBConnection $db
87
+     * @param ILogger $logger
88
+     */
89
+    public function __construct($user, $db, ILogger $logger) {
90
+        $this->logger = $logger;
91
+        $this->user = $user;
92
+        $this->db = $db;
93
+        // when DB locking is used, no DB transactions will be used
94
+        $this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider);
95
+    }
96 96
 
97
-	/**
98
-	 * get all storages for $dir
99
-	 *
100
-	 * @param string $dir
101
-	 * @return \OC\Files\Mount\MountPoint[]
102
-	 */
103
-	protected function getMounts($dir) {
104
-		//TODO: move to the node based fileapi once that's done
105
-		\OC_Util::tearDownFS();
106
-		\OC_Util::setupFS($this->user);
97
+    /**
98
+     * get all storages for $dir
99
+     *
100
+     * @param string $dir
101
+     * @return \OC\Files\Mount\MountPoint[]
102
+     */
103
+    protected function getMounts($dir) {
104
+        //TODO: move to the node based fileapi once that's done
105
+        \OC_Util::tearDownFS();
106
+        \OC_Util::setupFS($this->user);
107 107
 
108
-		$mountManager = Filesystem::getMountManager();
109
-		$mounts = $mountManager->findIn($dir);
110
-		$mounts[] = $mountManager->find($dir);
111
-		$mounts = array_reverse($mounts); //start with the mount of $dir
108
+        $mountManager = Filesystem::getMountManager();
109
+        $mounts = $mountManager->findIn($dir);
110
+        $mounts[] = $mountManager->find($dir);
111
+        $mounts = array_reverse($mounts); //start with the mount of $dir
112 112
 
113
-		return $mounts;
114
-	}
113
+        return $mounts;
114
+    }
115 115
 
116
-	/**
117
-	 * attach listeners to the scanner
118
-	 *
119
-	 * @param \OC\Files\Mount\MountPoint $mount
120
-	 */
121
-	protected function attachListener($mount) {
122
-		$scanner = $mount->getStorage()->getScanner();
123
-		$emitter = $this;
124
-		$scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) {
125
-			$emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path));
126
-		});
127
-		$scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) {
128
-			$emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path));
129
-		});
130
-		$scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) {
131
-			$emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path));
132
-		});
133
-		$scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) {
134
-			$emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path));
135
-		});
136
-	}
116
+    /**
117
+     * attach listeners to the scanner
118
+     *
119
+     * @param \OC\Files\Mount\MountPoint $mount
120
+     */
121
+    protected function attachListener($mount) {
122
+        $scanner = $mount->getStorage()->getScanner();
123
+        $emitter = $this;
124
+        $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) {
125
+            $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path));
126
+        });
127
+        $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) {
128
+            $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path));
129
+        });
130
+        $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) {
131
+            $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path));
132
+        });
133
+        $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) {
134
+            $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path));
135
+        });
136
+    }
137 137
 
138
-	/**
139
-	 * @param string $dir
140
-	 */
141
-	public function backgroundScan($dir) {
142
-		$mounts = $this->getMounts($dir);
143
-		foreach ($mounts as $mount) {
144
-			$storage = $mount->getStorage();
145
-			if (is_null($storage)) {
146
-				continue;
147
-			}
138
+    /**
139
+     * @param string $dir
140
+     */
141
+    public function backgroundScan($dir) {
142
+        $mounts = $this->getMounts($dir);
143
+        foreach ($mounts as $mount) {
144
+            $storage = $mount->getStorage();
145
+            if (is_null($storage)) {
146
+                continue;
147
+            }
148 148
 
149
-			// don't bother scanning failed storages (shortcut for same result)
150
-			if ($storage->instanceOfStorage(FailedStorage::class)) {
151
-				continue;
152
-			}
149
+            // don't bother scanning failed storages (shortcut for same result)
150
+            if ($storage->instanceOfStorage(FailedStorage::class)) {
151
+                continue;
152
+            }
153 153
 
154
-			// don't scan the root storage
155
-			if ($storage->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') {
156
-				continue;
157
-			}
154
+            // don't scan the root storage
155
+            if ($storage->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') {
156
+                continue;
157
+            }
158 158
 
159
-			// don't scan received local shares, these can be scanned when scanning the owner's storage
160
-			if ($storage->instanceOfStorage(SharedStorage::class)) {
161
-				continue;
162
-			}
163
-			$scanner = $storage->getScanner();
164
-			$this->attachListener($mount);
159
+            // don't scan received local shares, these can be scanned when scanning the owner's storage
160
+            if ($storage->instanceOfStorage(SharedStorage::class)) {
161
+                continue;
162
+            }
163
+            $scanner = $storage->getScanner();
164
+            $this->attachListener($mount);
165 165
 
166
-			$scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
167
-				$this->triggerPropagator($storage, $path);
168
-			});
169
-			$scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
170
-				$this->triggerPropagator($storage, $path);
171
-			});
172
-			$scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
173
-				$this->triggerPropagator($storage, $path);
174
-			});
166
+            $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
167
+                $this->triggerPropagator($storage, $path);
168
+            });
169
+            $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
170
+                $this->triggerPropagator($storage, $path);
171
+            });
172
+            $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
173
+                $this->triggerPropagator($storage, $path);
174
+            });
175 175
 
176
-			$propagator = $storage->getPropagator();
177
-			$propagator->beginBatch();
178
-			$scanner->backgroundScan();
179
-			$propagator->commitBatch();
180
-		}
181
-	}
176
+            $propagator = $storage->getPropagator();
177
+            $propagator->beginBatch();
178
+            $scanner->backgroundScan();
179
+            $propagator->commitBatch();
180
+        }
181
+    }
182 182
 
183
-	/**
184
-	 * @param string $dir
185
-	 * @param $recursive
186
-	 * @param callable|null $mountFilter
187
-	 * @throws ForbiddenException
188
-	 * @throws NotFoundException
189
-	 */
190
-	public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, callable $mountFilter = null) {
191
-		if (!Filesystem::isValidPath($dir)) {
192
-			throw new \InvalidArgumentException('Invalid path to scan');
193
-		}
194
-		$mounts = $this->getMounts($dir);
195
-		foreach ($mounts as $mount) {
196
-			if ($mountFilter && !$mountFilter($mount)) {
197
-				continue;
198
-			}
199
-			$storage = $mount->getStorage();
200
-			if (is_null($storage)) {
201
-				continue;
202
-			}
183
+    /**
184
+     * @param string $dir
185
+     * @param $recursive
186
+     * @param callable|null $mountFilter
187
+     * @throws ForbiddenException
188
+     * @throws NotFoundException
189
+     */
190
+    public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, callable $mountFilter = null) {
191
+        if (!Filesystem::isValidPath($dir)) {
192
+            throw new \InvalidArgumentException('Invalid path to scan');
193
+        }
194
+        $mounts = $this->getMounts($dir);
195
+        foreach ($mounts as $mount) {
196
+            if ($mountFilter && !$mountFilter($mount)) {
197
+                continue;
198
+            }
199
+            $storage = $mount->getStorage();
200
+            if (is_null($storage)) {
201
+                continue;
202
+            }
203 203
 
204
-			// don't bother scanning failed storages (shortcut for same result)
205
-			if ($storage->instanceOfStorage(FailedStorage::class)) {
206
-				continue;
207
-			}
204
+            // don't bother scanning failed storages (shortcut for same result)
205
+            if ($storage->instanceOfStorage(FailedStorage::class)) {
206
+                continue;
207
+            }
208 208
 
209
-			// if the home storage isn't writable then the scanner is run as the wrong user
210
-			if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and
211
-				(!$storage->isCreatable('') or !$storage->isCreatable('files'))
212
-			) {
213
-				if ($storage->file_exists('') or $storage->getCache()->inCache('')) {
214
-					throw new ForbiddenException();
215
-				} else {// if the root exists in neither the cache nor the storage the user isn't setup yet
216
-					break;
217
-				}
209
+            // if the home storage isn't writable then the scanner is run as the wrong user
210
+            if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and
211
+                (!$storage->isCreatable('') or !$storage->isCreatable('files'))
212
+            ) {
213
+                if ($storage->file_exists('') or $storage->getCache()->inCache('')) {
214
+                    throw new ForbiddenException();
215
+                } else {// if the root exists in neither the cache nor the storage the user isn't setup yet
216
+                    break;
217
+                }
218 218
 
219
-			}
219
+            }
220 220
 
221
-			// don't scan received local shares, these can be scanned when scanning the owner's storage
222
-			if ($storage->instanceOfStorage(SharedStorage::class)) {
223
-				continue;
224
-			}
225
-			$relativePath = $mount->getInternalPath($dir);
226
-			$scanner = $storage->getScanner();
227
-			$scanner->setUseTransactions(false);
228
-			$this->attachListener($mount);
221
+            // don't scan received local shares, these can be scanned when scanning the owner's storage
222
+            if ($storage->instanceOfStorage(SharedStorage::class)) {
223
+                continue;
224
+            }
225
+            $relativePath = $mount->getInternalPath($dir);
226
+            $scanner = $storage->getScanner();
227
+            $scanner->setUseTransactions(false);
228
+            $this->attachListener($mount);
229 229
 
230
-			$scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
231
-				$this->postProcessEntry($storage, $path);
232
-			});
233
-			$scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
234
-				$this->postProcessEntry($storage, $path);
235
-			});
236
-			$scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
237
-				$this->postProcessEntry($storage, $path);
238
-			});
230
+            $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) {
231
+                $this->postProcessEntry($storage, $path);
232
+            });
233
+            $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) {
234
+                $this->postProcessEntry($storage, $path);
235
+            });
236
+            $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) {
237
+                $this->postProcessEntry($storage, $path);
238
+            });
239 239
 
240
-			if (!$storage->file_exists($relativePath)) {
241
-				throw new NotFoundException($dir);
242
-			}
240
+            if (!$storage->file_exists($relativePath)) {
241
+                throw new NotFoundException($dir);
242
+            }
243 243
 
244
-			if ($this->useTransaction) {
245
-				$this->db->beginTransaction();
246
-			}
247
-			try {
248
-				$propagator = $storage->getPropagator();
249
-				$propagator->beginBatch();
250
-				$scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
251
-				$cache = $storage->getCache();
252
-				if ($cache instanceof Cache) {
253
-					// only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner
254
-					$cache->correctFolderSize($relativePath);
255
-				}
256
-				$propagator->commitBatch();
257
-			} catch (StorageNotAvailableException $e) {
258
-				$this->logger->error('Storage ' . $storage->getId() . ' not available');
259
-				$this->logger->logException($e);
260
-				$this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]);
261
-			}
262
-			if ($this->useTransaction) {
263
-				$this->db->commit();
264
-			}
265
-		}
266
-	}
244
+            if ($this->useTransaction) {
245
+                $this->db->beginTransaction();
246
+            }
247
+            try {
248
+                $propagator = $storage->getPropagator();
249
+                $propagator->beginBatch();
250
+                $scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
251
+                $cache = $storage->getCache();
252
+                if ($cache instanceof Cache) {
253
+                    // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner
254
+                    $cache->correctFolderSize($relativePath);
255
+                }
256
+                $propagator->commitBatch();
257
+            } catch (StorageNotAvailableException $e) {
258
+                $this->logger->error('Storage ' . $storage->getId() . ' not available');
259
+                $this->logger->logException($e);
260
+                $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]);
261
+            }
262
+            if ($this->useTransaction) {
263
+                $this->db->commit();
264
+            }
265
+        }
266
+    }
267 267
 
268
-	private function triggerPropagator(IStorage $storage, $internalPath) {
269
-		$storage->getPropagator()->propagateChange($internalPath, time());
270
-	}
268
+    private function triggerPropagator(IStorage $storage, $internalPath) {
269
+        $storage->getPropagator()->propagateChange($internalPath, time());
270
+    }
271 271
 
272
-	private function postProcessEntry(IStorage $storage, $internalPath) {
273
-		$this->triggerPropagator($storage, $internalPath);
274
-		if ($this->useTransaction) {
275
-			$this->entriesToCommit++;
276
-			if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT) {
277
-				$propagator = $storage->getPropagator();
278
-				$this->entriesToCommit = 0;
279
-				$this->db->commit();
280
-				$propagator->commitBatch();
281
-				$this->db->beginTransaction();
282
-				$propagator->beginBatch();
283
-			}
284
-		}
285
-	}
272
+    private function postProcessEntry(IStorage $storage, $internalPath) {
273
+        $this->triggerPropagator($storage, $internalPath);
274
+        if ($this->useTransaction) {
275
+            $this->entriesToCommit++;
276
+            if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT) {
277
+                $propagator = $storage->getPropagator();
278
+                $this->entriesToCommit = 0;
279
+                $this->db->commit();
280
+                $propagator->commitBatch();
281
+                $this->db->beginTransaction();
282
+                $propagator->beginBatch();
283
+            }
284
+        }
285
+    }
286 286
 }
287 287
 
Please login to merge, or discard this patch.
apps/files/lib/Command/Scan.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -45,324 +45,324 @@
 block discarded – undo
45 45
 
46 46
 class Scan extends Base {
47 47
 
48
-	/** @var IUserManager $userManager */
49
-	private $userManager;
50
-	/** @var float */
51
-	protected $execTime = 0;
52
-	/** @var int */
53
-	protected $foldersCounter = 0;
54
-	/** @var int */
55
-	protected $filesCounter = 0;
48
+    /** @var IUserManager $userManager */
49
+    private $userManager;
50
+    /** @var float */
51
+    protected $execTime = 0;
52
+    /** @var int */
53
+    protected $foldersCounter = 0;
54
+    /** @var int */
55
+    protected $filesCounter = 0;
56 56
 
57
-	public function __construct(IUserManager $userManager) {
58
-		$this->userManager = $userManager;
59
-		parent::__construct();
60
-	}
57
+    public function __construct(IUserManager $userManager) {
58
+        $this->userManager = $userManager;
59
+        parent::__construct();
60
+    }
61 61
 
62
-	protected function configure() {
63
-		parent::configure();
62
+    protected function configure() {
63
+        parent::configure();
64 64
 
65
-		$this
66
-			->setName('files:scan')
67
-			->setDescription('rescan filesystem')
68
-			->addArgument(
69
-				'user_id',
70
-				InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
71
-				'will rescan all files of the given user(s)'
72
-			)
73
-			->addOption(
74
-				'path',
75
-				'p',
76
-				InputArgument::OPTIONAL,
77
-				'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'
78
-			)
79
-			->addOption(
80
-				'quiet',
81
-				'q',
82
-				InputOption::VALUE_NONE,
83
-				'suppress any output'
84
-			)
85
-			->addOption(
86
-				'verbose',
87
-				'-v|vv|vvv',
88
-				InputOption::VALUE_NONE,
89
-				'verbose the output'
90
-			)
91
-			->addOption(
92
-				'all',
93
-				null,
94
-				InputOption::VALUE_NONE,
95
-				'will rescan all files of all known users'
96
-			)->addOption(
97
-				'unscanned',
98
-				null,
99
-				InputOption::VALUE_NONE,
100
-				'only scan files which are marked as not fully scanned'
101
-			)->addOption(
102
-				'shallow',
103
-				null,
104
-				InputOption::VALUE_NONE,
105
-				'do not scan folders recursively'
106
-			)->addOption(
107
-				'home-only',
108
-				null,
109
-				InputOption::VALUE_NONE,
110
-				'only scan the home storage, ignoring any mounted external storage or share'
111
-			);
112
-	}
65
+        $this
66
+            ->setName('files:scan')
67
+            ->setDescription('rescan filesystem')
68
+            ->addArgument(
69
+                'user_id',
70
+                InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
71
+                'will rescan all files of the given user(s)'
72
+            )
73
+            ->addOption(
74
+                'path',
75
+                'p',
76
+                InputArgument::OPTIONAL,
77
+                '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'
78
+            )
79
+            ->addOption(
80
+                'quiet',
81
+                'q',
82
+                InputOption::VALUE_NONE,
83
+                'suppress any output'
84
+            )
85
+            ->addOption(
86
+                'verbose',
87
+                '-v|vv|vvv',
88
+                InputOption::VALUE_NONE,
89
+                'verbose the output'
90
+            )
91
+            ->addOption(
92
+                'all',
93
+                null,
94
+                InputOption::VALUE_NONE,
95
+                'will rescan all files of all known users'
96
+            )->addOption(
97
+                'unscanned',
98
+                null,
99
+                InputOption::VALUE_NONE,
100
+                'only scan files which are marked as not fully scanned'
101
+            )->addOption(
102
+                'shallow',
103
+                null,
104
+                InputOption::VALUE_NONE,
105
+                'do not scan folders recursively'
106
+            )->addOption(
107
+                'home-only',
108
+                null,
109
+                InputOption::VALUE_NONE,
110
+                'only scan the home storage, ignoring any mounted external storage or share'
111
+            );
112
+    }
113 113
 
114
-	public function checkScanWarning($fullPath, OutputInterface $output) {
115
-		$normalizedPath = basename(\OC\Files\Filesystem::normalizePath($fullPath));
116
-		$path = basename($fullPath);
114
+    public function checkScanWarning($fullPath, OutputInterface $output) {
115
+        $normalizedPath = basename(\OC\Files\Filesystem::normalizePath($fullPath));
116
+        $path = basename($fullPath);
117 117
 
118
-		if ($normalizedPath !== $path) {
119
-			$output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
120
-		}
121
-	}
118
+        if ($normalizedPath !== $path) {
119
+            $output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
120
+        }
121
+    }
122 122
 
123
-	protected function scanFiles($user, $path, $verbose, OutputInterface $output, $backgroundScan = false, $recursive = true, $homeOnly = false) {
124
-		$connection = $this->reconnectToDatabase($output);
125
-		$scanner = new \OC\Files\Utils\Scanner($user, $connection, \OC::$server->getLogger());
126
-		# check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
127
-		# printout and count
128
-		if ($verbose) {
129
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
130
-				$output->writeln("\tFile   <info>$path</info>");
131
-				$this->filesCounter += 1;
132
-				if ($this->hasBeenInterrupted()) {
133
-					throw new InterruptedException();
134
-				}
135
-			});
136
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
137
-				$output->writeln("\tFolder <info>$path</info>");
138
-				$this->foldersCounter += 1;
139
-				if ($this->hasBeenInterrupted()) {
140
-					throw new InterruptedException();
141
-				}
142
-			});
143
-			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
144
-				$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
145
-			});
146
-			# count only
147
-		} else {
148
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
149
-				$this->filesCounter += 1;
150
-				if ($this->hasBeenInterrupted()) {
151
-					throw new InterruptedException();
152
-				}
153
-			});
154
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
155
-				$this->foldersCounter += 1;
156
-				if ($this->hasBeenInterrupted()) {
157
-					throw new InterruptedException();
158
-				}
159
-			});
160
-		}
161
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
162
-			$this->checkScanWarning($path, $output);
163
-		});
164
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
165
-			$this->checkScanWarning($path, $output);
166
-		});
123
+    protected function scanFiles($user, $path, $verbose, OutputInterface $output, $backgroundScan = false, $recursive = true, $homeOnly = false) {
124
+        $connection = $this->reconnectToDatabase($output);
125
+        $scanner = new \OC\Files\Utils\Scanner($user, $connection, \OC::$server->getLogger());
126
+        # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
127
+        # printout and count
128
+        if ($verbose) {
129
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
130
+                $output->writeln("\tFile   <info>$path</info>");
131
+                $this->filesCounter += 1;
132
+                if ($this->hasBeenInterrupted()) {
133
+                    throw new InterruptedException();
134
+                }
135
+            });
136
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
137
+                $output->writeln("\tFolder <info>$path</info>");
138
+                $this->foldersCounter += 1;
139
+                if ($this->hasBeenInterrupted()) {
140
+                    throw new InterruptedException();
141
+                }
142
+            });
143
+            $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
144
+                $output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
145
+            });
146
+            # count only
147
+        } else {
148
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
149
+                $this->filesCounter += 1;
150
+                if ($this->hasBeenInterrupted()) {
151
+                    throw new InterruptedException();
152
+                }
153
+            });
154
+            $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
155
+                $this->foldersCounter += 1;
156
+                if ($this->hasBeenInterrupted()) {
157
+                    throw new InterruptedException();
158
+                }
159
+            });
160
+        }
161
+        $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
162
+            $this->checkScanWarning($path, $output);
163
+        });
164
+        $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
165
+            $this->checkScanWarning($path, $output);
166
+        });
167 167
 
168
-		try {
169
-			if ($backgroundScan) {
170
-				$scanner->backgroundScan($path);
171
-			} else {
172
-				$scanner->scan($path, $recursive, $homeOnly ? [$this, 'filterHomeMount'] : null);
173
-			}
174
-		} catch (ForbiddenException $e) {
175
-			$output->writeln("<error>Home storage for user $user not writable</error>");
176
-			$output->writeln("Make sure you're running the scan command only as the user the web server runs as");
177
-		} catch (InterruptedException $e) {
178
-			# exit the function if ctrl-c has been pressed
179
-			$output->writeln('Interrupted by user');
180
-		} catch (NotFoundException $e) {
181
-			$output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
182
-		} catch (\Exception $e) {
183
-			$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
184
-			$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
185
-		}
186
-	}
168
+        try {
169
+            if ($backgroundScan) {
170
+                $scanner->backgroundScan($path);
171
+            } else {
172
+                $scanner->scan($path, $recursive, $homeOnly ? [$this, 'filterHomeMount'] : null);
173
+            }
174
+        } catch (ForbiddenException $e) {
175
+            $output->writeln("<error>Home storage for user $user not writable</error>");
176
+            $output->writeln("Make sure you're running the scan command only as the user the web server runs as");
177
+        } catch (InterruptedException $e) {
178
+            # exit the function if ctrl-c has been pressed
179
+            $output->writeln('Interrupted by user');
180
+        } catch (NotFoundException $e) {
181
+            $output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
182
+        } catch (\Exception $e) {
183
+            $output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
184
+            $output->writeln('<error>' . $e->getTraceAsString() . '</error>');
185
+        }
186
+    }
187 187
 
188
-	public function filterHomeMount(IMountPoint $mountPoint) {
189
-		// any mountpoint inside '/$user/files/'
190
-		return substr_count($mountPoint->getMountPoint(), '/') <= 3;
191
-	}
188
+    public function filterHomeMount(IMountPoint $mountPoint) {
189
+        // any mountpoint inside '/$user/files/'
190
+        return substr_count($mountPoint->getMountPoint(), '/') <= 3;
191
+    }
192 192
 
193
-	protected function execute(InputInterface $input, OutputInterface $output) {
194
-		$inputPath = $input->getOption('path');
195
-		if ($inputPath) {
196
-			$inputPath = '/' . trim($inputPath, '/');
197
-			list (, $user,) = explode('/', $inputPath, 3);
198
-			$users = array($user);
199
-		} else if ($input->getOption('all')) {
200
-			$users = $this->userManager->search('');
201
-		} else {
202
-			$users = $input->getArgument('user_id');
203
-		}
193
+    protected function execute(InputInterface $input, OutputInterface $output) {
194
+        $inputPath = $input->getOption('path');
195
+        if ($inputPath) {
196
+            $inputPath = '/' . trim($inputPath, '/');
197
+            list (, $user,) = explode('/', $inputPath, 3);
198
+            $users = array($user);
199
+        } else if ($input->getOption('all')) {
200
+            $users = $this->userManager->search('');
201
+        } else {
202
+            $users = $input->getArgument('user_id');
203
+        }
204 204
 
205
-		# no messaging level option means: no full printout but statistics
206
-		# $quiet   means no print at all
207
-		# $verbose means full printout including statistics
208
-		# -q	-v	full	stat
209
-		#  0	 0	no	yes
210
-		#  0	 1	yes	yes
211
-		#  1	--	no	no  (quiet overrules verbose)
212
-		$verbose = $input->getOption('verbose');
213
-		$quiet = $input->getOption('quiet');
214
-		# restrict the verbosity level to VERBOSITY_VERBOSE
215
-		if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
216
-			$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
217
-		}
218
-		if ($quiet) {
219
-			$verbose = false;
220
-		}
205
+        # no messaging level option means: no full printout but statistics
206
+        # $quiet   means no print at all
207
+        # $verbose means full printout including statistics
208
+        # -q	-v	full	stat
209
+        #  0	 0	no	yes
210
+        #  0	 1	yes	yes
211
+        #  1	--	no	no  (quiet overrules verbose)
212
+        $verbose = $input->getOption('verbose');
213
+        $quiet = $input->getOption('quiet');
214
+        # restrict the verbosity level to VERBOSITY_VERBOSE
215
+        if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
216
+            $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
217
+        }
218
+        if ($quiet) {
219
+            $verbose = false;
220
+        }
221 221
 
222
-		# check quantity of users to be process and show it on the command line
223
-		$users_total = count($users);
224
-		if ($users_total === 0) {
225
-			$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
226
-			return;
227
-		} else {
228
-			if ($users_total > 1) {
229
-				$output->writeln("\nScanning files for $users_total users");
230
-			}
231
-		}
222
+        # check quantity of users to be process and show it on the command line
223
+        $users_total = count($users);
224
+        if ($users_total === 0) {
225
+            $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
226
+            return;
227
+        } else {
228
+            if ($users_total > 1) {
229
+                $output->writeln("\nScanning files for $users_total users");
230
+            }
231
+        }
232 232
 
233
-		$this->initTools();
233
+        $this->initTools();
234 234
 
235
-		$user_count = 0;
236
-		foreach ($users as $user) {
237
-			if (is_object($user)) {
238
-				$user = $user->getUID();
239
-			}
240
-			$path = $inputPath ? $inputPath : '/' . $user;
241
-			$user_count += 1;
242
-			if ($this->userManager->userExists($user)) {
243
-				# add an extra line when verbose is set to optical separate users
244
-				if ($verbose) {
245
-					$output->writeln("");
246
-				}
247
-				$output->writeln("Starting scan for user $user_count out of $users_total ($user)");
248
-				# full: printout data if $verbose was set
249
-				$this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'), ! $input->getOption('shallow'), $input->getOption('home-only'));
250
-			} else {
251
-				$output->writeln("<error>Unknown user $user_count $user</error>");
252
-			}
253
-			# check on each user if there was a user interrupt (ctrl-c) and exit foreach
254
-			if ($this->hasBeenInterrupted()) {
255
-				break;
256
-			}
257
-		}
235
+        $user_count = 0;
236
+        foreach ($users as $user) {
237
+            if (is_object($user)) {
238
+                $user = $user->getUID();
239
+            }
240
+            $path = $inputPath ? $inputPath : '/' . $user;
241
+            $user_count += 1;
242
+            if ($this->userManager->userExists($user)) {
243
+                # add an extra line when verbose is set to optical separate users
244
+                if ($verbose) {
245
+                    $output->writeln("");
246
+                }
247
+                $output->writeln("Starting scan for user $user_count out of $users_total ($user)");
248
+                # full: printout data if $verbose was set
249
+                $this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'), ! $input->getOption('shallow'), $input->getOption('home-only'));
250
+            } else {
251
+                $output->writeln("<error>Unknown user $user_count $user</error>");
252
+            }
253
+            # check on each user if there was a user interrupt (ctrl-c) and exit foreach
254
+            if ($this->hasBeenInterrupted()) {
255
+                break;
256
+            }
257
+        }
258 258
 
259
-		# stat: printout statistics if $quiet was not set
260
-		if (!$quiet) {
261
-			$this->presentStats($output);
262
-		}
263
-	}
259
+        # stat: printout statistics if $quiet was not set
260
+        if (!$quiet) {
261
+            $this->presentStats($output);
262
+        }
263
+    }
264 264
 
265
-	/**
266
-	 * Initialises some useful tools for the Command
267
-	 */
268
-	protected function initTools() {
269
-		// Start the timer
270
-		$this->execTime = -microtime(true);
271
-		// Convert PHP errors to exceptions
272
-		set_error_handler([$this, 'exceptionErrorHandler'], E_ALL);
273
-	}
265
+    /**
266
+     * Initialises some useful tools for the Command
267
+     */
268
+    protected function initTools() {
269
+        // Start the timer
270
+        $this->execTime = -microtime(true);
271
+        // Convert PHP errors to exceptions
272
+        set_error_handler([$this, 'exceptionErrorHandler'], E_ALL);
273
+    }
274 274
 
275
-	/**
276
-	 * Processes PHP errors as exceptions in order to be able to keep track of problems
277
-	 *
278
-	 * @see https://secure.php.net/manual/en/function.set-error-handler.php
279
-	 *
280
-	 * @param int $severity the level of the error raised
281
-	 * @param string $message
282
-	 * @param string $file the filename that the error was raised in
283
-	 * @param int $line the line number the error was raised
284
-	 *
285
-	 * @throws \ErrorException
286
-	 */
287
-	public function exceptionErrorHandler($severity, $message, $file, $line) {
288
-		if (!(error_reporting() & $severity)) {
289
-			// This error code is not included in error_reporting
290
-			return;
291
-		}
292
-		throw new \ErrorException($message, 0, $severity, $file, $line);
293
-	}
275
+    /**
276
+     * Processes PHP errors as exceptions in order to be able to keep track of problems
277
+     *
278
+     * @see https://secure.php.net/manual/en/function.set-error-handler.php
279
+     *
280
+     * @param int $severity the level of the error raised
281
+     * @param string $message
282
+     * @param string $file the filename that the error was raised in
283
+     * @param int $line the line number the error was raised
284
+     *
285
+     * @throws \ErrorException
286
+     */
287
+    public function exceptionErrorHandler($severity, $message, $file, $line) {
288
+        if (!(error_reporting() & $severity)) {
289
+            // This error code is not included in error_reporting
290
+            return;
291
+        }
292
+        throw new \ErrorException($message, 0, $severity, $file, $line);
293
+    }
294 294
 
295
-	/**
296
-	 * @param OutputInterface $output
297
-	 */
298
-	protected function presentStats(OutputInterface $output) {
299
-		// Stop the timer
300
-		$this->execTime += microtime(true);
301
-		$output->writeln("");
295
+    /**
296
+     * @param OutputInterface $output
297
+     */
298
+    protected function presentStats(OutputInterface $output) {
299
+        // Stop the timer
300
+        $this->execTime += microtime(true);
301
+        $output->writeln("");
302 302
 
303
-		$headers = [
304
-			'Folders', 'Files', 'Elapsed time'
305
-		];
303
+        $headers = [
304
+            'Folders', 'Files', 'Elapsed time'
305
+        ];
306 306
 
307
-		$this->showSummary($headers, null, $output);
308
-	}
307
+        $this->showSummary($headers, null, $output);
308
+    }
309 309
 
310
-	/**
311
-	 * Shows a summary of operations
312
-	 *
313
-	 * @param string[] $headers
314
-	 * @param string[] $rows
315
-	 * @param OutputInterface $output
316
-	 */
317
-	protected function showSummary($headers, $rows, OutputInterface $output) {
318
-		$niceDate = $this->formatExecTime();
319
-		if (!$rows) {
320
-			$rows = [
321
-				$this->foldersCounter,
322
-				$this->filesCounter,
323
-				$niceDate,
324
-			];
325
-		}
326
-		$table = new Table($output);
327
-		$table
328
-			->setHeaders($headers)
329
-			->setRows([$rows]);
330
-		$table->render();
331
-	}
310
+    /**
311
+     * Shows a summary of operations
312
+     *
313
+     * @param string[] $headers
314
+     * @param string[] $rows
315
+     * @param OutputInterface $output
316
+     */
317
+    protected function showSummary($headers, $rows, OutputInterface $output) {
318
+        $niceDate = $this->formatExecTime();
319
+        if (!$rows) {
320
+            $rows = [
321
+                $this->foldersCounter,
322
+                $this->filesCounter,
323
+                $niceDate,
324
+            ];
325
+        }
326
+        $table = new Table($output);
327
+        $table
328
+            ->setHeaders($headers)
329
+            ->setRows([$rows]);
330
+        $table->render();
331
+    }
332 332
 
333 333
 
334
-	/**
335
-	 * Formats microtime into a human readable format
336
-	 *
337
-	 * @return string
338
-	 */
339
-	protected function formatExecTime() {
340
-		list($secs, ) = explode('.', sprintf("%.1f", $this->execTime));
334
+    /**
335
+     * Formats microtime into a human readable format
336
+     *
337
+     * @return string
338
+     */
339
+    protected function formatExecTime() {
340
+        list($secs, ) = explode('.', sprintf("%.1f", $this->execTime));
341 341
 
342
-		# if you want to have microseconds add this:   . '.' . $tens;
343
-		return date('H:i:s', $secs);
344
-	}
342
+        # if you want to have microseconds add this:   . '.' . $tens;
343
+        return date('H:i:s', $secs);
344
+    }
345 345
 
346
-	/**
347
-	 * @return \OCP\IDBConnection
348
-	 */
349
-	protected function reconnectToDatabase(OutputInterface $output) {
350
-		/** @var Connection | IDBConnection $connection */
351
-		$connection = \OC::$server->getDatabaseConnection();
352
-		try {
353
-			$connection->close();
354
-		} catch (\Exception $ex) {
355
-			$output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
356
-		}
357
-		while (!$connection->isConnected()) {
358
-			try {
359
-				$connection->connect();
360
-			} catch (\Exception $ex) {
361
-				$output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
362
-				sleep(60);
363
-			}
364
-		}
365
-		return $connection;
366
-	}
346
+    /**
347
+     * @return \OCP\IDBConnection
348
+     */
349
+    protected function reconnectToDatabase(OutputInterface $output) {
350
+        /** @var Connection | IDBConnection $connection */
351
+        $connection = \OC::$server->getDatabaseConnection();
352
+        try {
353
+            $connection->close();
354
+        } catch (\Exception $ex) {
355
+            $output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
356
+        }
357
+        while (!$connection->isConnected()) {
358
+            try {
359
+                $connection->connect();
360
+            } catch (\Exception $ex) {
361
+                $output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
362
+                sleep(60);
363
+            }
364
+        }
365
+        return $connection;
366
+    }
367 367
 
368 368
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$path = basename($fullPath);
117 117
 
118 118
 		if ($normalizedPath !== $path) {
119
-			$output->writeln("\t<error>Entry \"" . $fullPath . '" will not be accessible due to incompatible encoding</error>');
119
+			$output->writeln("\t<error>Entry \"".$fullPath.'" will not be accessible due to incompatible encoding</error>');
120 120
 		}
121 121
 	}
122 122
 
@@ -126,42 +126,42 @@  discard block
 block discarded – undo
126 126
 		# check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception
127 127
 		# printout and count
128 128
 		if ($verbose) {
129
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
129
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
130 130
 				$output->writeln("\tFile   <info>$path</info>");
131 131
 				$this->filesCounter += 1;
132 132
 				if ($this->hasBeenInterrupted()) {
133 133
 					throw new InterruptedException();
134 134
 				}
135 135
 			});
136
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
136
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) {
137 137
 				$output->writeln("\tFolder <info>$path</info>");
138 138
 				$this->foldersCounter += 1;
139 139
 				if ($this->hasBeenInterrupted()) {
140 140
 					throw new InterruptedException();
141 141
 				}
142 142
 			});
143
-			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) {
144
-				$output->writeln("Error while scanning, storage not available (" . $e->getMessage() . ")");
143
+			$scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function(StorageNotAvailableException $e) use ($output) {
144
+				$output->writeln("Error while scanning, storage not available (".$e->getMessage().")");
145 145
 			});
146 146
 			# count only
147 147
 		} else {
148
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function () use ($output) {
148
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function() use ($output) {
149 149
 				$this->filesCounter += 1;
150 150
 				if ($this->hasBeenInterrupted()) {
151 151
 					throw new InterruptedException();
152 152
 				}
153 153
 			});
154
-			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function () use ($output) {
154
+			$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function() use ($output) {
155 155
 				$this->foldersCounter += 1;
156 156
 				if ($this->hasBeenInterrupted()) {
157 157
 					throw new InterruptedException();
158 158
 				}
159 159
 			});
160 160
 		}
161
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
161
+		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) use ($output) {
162 162
 			$this->checkScanWarning($path, $output);
163 163
 		});
164
-		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
164
+		$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) use ($output) {
165 165
 			$this->checkScanWarning($path, $output);
166 166
 		});
167 167
 
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 			# exit the function if ctrl-c has been pressed
179 179
 			$output->writeln('Interrupted by user');
180 180
 		} catch (NotFoundException $e) {
181
-			$output->writeln('<error>Path not found: ' . $e->getMessage() . '</error>');
181
+			$output->writeln('<error>Path not found: '.$e->getMessage().'</error>');
182 182
 		} catch (\Exception $e) {
183
-			$output->writeln('<error>Exception during scan: ' . $e->getMessage() . '</error>');
184
-			$output->writeln('<error>' . $e->getTraceAsString() . '</error>');
183
+			$output->writeln('<error>Exception during scan: '.$e->getMessage().'</error>');
184
+			$output->writeln('<error>'.$e->getTraceAsString().'</error>');
185 185
 		}
186 186
 	}
187 187
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	protected function execute(InputInterface $input, OutputInterface $output) {
194 194
 		$inputPath = $input->getOption('path');
195 195
 		if ($inputPath) {
196
-			$inputPath = '/' . trim($inputPath, '/');
196
+			$inputPath = '/'.trim($inputPath, '/');
197 197
 			list (, $user,) = explode('/', $inputPath, 3);
198 198
 			$users = array($user);
199 199
 		} else if ($input->getOption('all')) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			if (is_object($user)) {
238 238
 				$user = $user->getUID();
239 239
 			}
240
-			$path = $inputPath ? $inputPath : '/' . $user;
240
+			$path = $inputPath ? $inputPath : '/'.$user;
241 241
 			$user_count += 1;
242 242
 			if ($this->userManager->userExists($user)) {
243 243
 				# add an extra line when verbose is set to optical separate users
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				}
247 247
 				$output->writeln("Starting scan for user $user_count out of $users_total ($user)");
248 248
 				# full: printout data if $verbose was set
249
-				$this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'), ! $input->getOption('shallow'), $input->getOption('home-only'));
249
+				$this->scanFiles($user, $path, $verbose, $output, $input->getOption('unscanned'), !$input->getOption('shallow'), $input->getOption('home-only'));
250 250
 			} else {
251 251
 				$output->writeln("<error>Unknown user $user_count $user</error>");
252 252
 			}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @return string
338 338
 	 */
339 339
 	protected function formatExecTime() {
340
-		list($secs, ) = explode('.', sprintf("%.1f", $this->execTime));
340
+		list($secs,) = explode('.', sprintf("%.1f", $this->execTime));
341 341
 
342 342
 		# if you want to have microseconds add this:   . '.' . $tens;
343 343
 		return date('H:i:s', $secs);
Please login to merge, or discard this patch.