aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache/Scanner.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-12 18:08:14 +0200
committerRobin Appelman <robin@icewind.nl>2023-05-10 19:33:26 +0200
commit2ea41dab93324749164e7c9c380085b8daab6138 (patch)
treea6094b9b32f97b35ec92fb2a52455c59ac7d5597 /lib/private/Files/Cache/Scanner.php
parentf734a7646639549b626c05b12a789c8cdedf2511 (diff)
downloadnextcloud-server-2ea41dab93324749164e7c9c380085b8daab6138.tar.gz
nextcloud-server-2ea41dab93324749164e7c9c380085b8daab6138.zip
repair -1 folder sizes for object store background scan
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Cache/Scanner.php')
-rw-r--r--lib/private/Files/Cache/Scanner.php17
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]);