Code Duplication    Length = 18-18 lines in 2 locations

apps/files/lib/Command/Scan.php 1 location

@@ 343-360 (lines=18) @@
340
	/**
341
	 * @return \OCP\IDBConnection
342
	 */
343
	protected function reconnectToDatabase(OutputInterface $output) {
344
		/** @var Connection | IDBConnection $connection */
345
		$connection = \OC::$server->getDatabaseConnection();
346
		try {
347
			$connection->close();
348
		} catch (\Exception $ex) {
349
			$output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
350
		}
351
		while (!$connection->isConnected()) {
352
			try {
353
				$connection->connect();
354
			} catch (\Exception $ex) {
355
				$output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
356
				sleep(60);
357
			}
358
		}
359
		return $connection;
360
	}
361
362
}
363

apps/files/lib/Command/ScanAppData.php 1 location

@@ 264-281 (lines=18) @@
261
	/**
262
	 * @return \OCP\IDBConnection
263
	 */
264
	protected function reconnectToDatabase(OutputInterface $output) {
265
		/** @var Connection | IDBConnection $connection*/
266
		$connection = \OC::$server->getDatabaseConnection();
267
		try {
268
			$connection->close();
269
		} catch (\Exception $ex) {
270
			$output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
271
		}
272
		while (!$connection->isConnected()) {
273
			try {
274
				$connection->connect();
275
			} catch (\Exception $ex) {
276
				$output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
277
				sleep(60);
278
			}
279
		}
280
		return $connection;
281
	}
282
283
	/**
284
	 * @return \OCP\Files\Folder