diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-01-11 16:38:31 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-01-11 16:45:14 +0100 |
commit | 3678823748b20d361f465b1b3ef03d1376aba19c (patch) | |
tree | df1692cb19b44d745711316b7ccab879158c2002 /apps/files/lib/Command/Scan.php | |
parent | fdd111924fc38aebd23ca2db9ecebfc4480eb026 (diff) | |
download | nextcloud-server-3678823748b20d361f465b1b3ef03d1376aba19c.tar.gz nextcloud-server-3678823748b20d361f465b1b3ef03d1376aba19c.zip |
Fix database connection usage in the files scanner
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files/lib/Command/Scan.php')
-rw-r--r-- | apps/files/lib/Command/Scan.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 3e8e1911aef..d8156da3669 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -35,15 +35,15 @@ namespace OCA\Files\Command; -use Doctrine\DBAL\Connection; use OC\Core\Command\Base; use OC\Core\Command\InterruptedException; +use OC\DB\Connection; +use OC\DB\ConnectionAdapter; use OC\ForbiddenException; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; -use OCP\IDBConnection; use OCP\IUserManager; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; @@ -118,7 +118,12 @@ class Scan extends Base { protected function scanFiles($user, $path, OutputInterface $output, $backgroundScan = false, $recursive = true, $homeOnly = false) { $connection = $this->reconnectToDatabase($output); - $scanner = new \OC\Files\Utils\Scanner($user, $connection, \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new \OC\Files\Utils\Scanner( + $user, + new ConnectionAdapter($connection), + \OC::$server->query(IEventDispatcher::class), + \OC::$server->getLogger() + ); # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception @@ -303,12 +308,9 @@ class Scan extends Base { return sprintf('%02d:%02d:%02d', ($secs / 3600), ($secs / 60 % 60), $secs % 60); } - /** - * @return \OCP\IDBConnection - */ - protected function reconnectToDatabase(OutputInterface $output) { - /** @var Connection | IDBConnection $connection */ - $connection = \OC::$server->getDatabaseConnection(); + protected function reconnectToDatabase(OutputInterface $output): Connection { + /** @var Connection $connection */ + $connection = \OC::$server->get(Connection::class); try { $connection->close(); } catch (\Exception $ex) { |