diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-05-11 08:15:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 08:15:41 +0200 |
commit | db026840082432f8b851171a8f0e8374de818ee1 (patch) | |
tree | a382d483b4e7abf752c0127f04667a4dd83e653a /lib/private/Files/Cache/Scanner.php | |
parent | 83ed1fb004e6fe3bb96171defbdafc89e302a72a (diff) | |
parent | 2ea41dab93324749164e7c9c380085b8daab6138 (diff) | |
download | nextcloud-server-db026840082432f8b851171a8f0e8374de818ee1.tar.gz nextcloud-server-db026840082432f8b851171a8f0e8374de818ee1.zip |
Merge pull request #37691 from nextcloud/object-store-background-scan
Diffstat (limited to 'lib/private/Files/Cache/Scanner.php')
-rw-r--r-- | lib/private/Files/Cache/Scanner.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 6969828782a..e3a08264716 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -41,8 +41,8 @@ use OCP\Files\Cache\IScanner; use OCP\Files\ForbiddenException; use OCP\Files\NotFoundException; use OCP\Files\Storage\IReliableEtagStorage; +use OCP\IDBConnection; use OCP\Lock\ILockingProvider; -use OC\Files\Storage\Wrapper\Encoding; use OC\Files\Storage\Wrapper\Jail; use OC\Hooks\BasicEmitter; use Psr\Log\LoggerInterface; @@ -89,12 +89,15 @@ class Scanner extends BasicEmitter implements IScanner { */ protected $lockingProvider; + protected IDBConnection $connection; + public function __construct(\OC\Files\Storage\Storage $storage) { $this->storage = $storage; $this->storageId = $this->storage->getId(); $this->cache = $storage->getCache(); $this->cacheActive = !\OC::$server->getConfig()->getSystemValueBool('filesystem_cache_readonly', false); $this->lockingProvider = \OC::$server->getLockingProvider(); + $this->connection = \OC::$server->get(IDBConnection::class); } /** @@ -430,7 +433,7 @@ class Scanner extends BasicEmitter implements IScanner { } if ($this->useTransactions) { - \OC::$server->getDatabaseConnection()->beginTransaction(); + $this->connection->beginTransaction(); } $exceptionOccurred = false; @@ -473,8 +476,8 @@ class Scanner extends BasicEmitter implements IScanner { // process is running in parallel // log and ignore if ($this->useTransactions) { - \OC::$server->getDatabaseConnection()->rollback(); - \OC::$server->getDatabaseConnection()->beginTransaction(); + $this->connection->rollback(); + $this->connection->beginTransaction(); } \OC::$server->get(LoggerInterface::class)->debug('Exception while scanning file "' . $child . '"', [ 'app' => 'core', @@ -483,7 +486,7 @@ class Scanner extends BasicEmitter implements IScanner { $exceptionOccurred = true; } catch (\OCP\Lock\LockedException $e) { if ($this->useTransactions) { - \OC::$server->getDatabaseConnection()->rollback(); + $this->connection->rollback(); } throw $e; } @@ -494,7 +497,7 @@ class Scanner extends BasicEmitter implements IScanner { $this->removeFromCache($child); } if ($this->useTransactions) { - \OC::$server->getDatabaseConnection()->commit(); + $this->connection->commit(); } if ($exceptionOccurred) { // It might happen that the parallel scan process has already @@ -558,7 +561,7 @@ class Scanner extends BasicEmitter implements IScanner { } } - private function runBackgroundScanJob(callable $callback, $path) { + protected function runBackgroundScanJob(callable $callback, $path) { try { $callback(); \OC_Hook::emit('Scanner', 'correctFolderSize', ['path' => $path]); |