Code Duplication    Length = 18-18 lines in 2 locations

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

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

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

@@ 349-366 (lines=18) @@
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
368
}
369