Skip to content

Commit

Permalink
Merge pull request #40144 from summersab/refactor/OC-Server-getLockin…
Browse files Browse the repository at this point in the history
…gProvider
  • Loading branch information
skjnldsv authored Mar 15, 2024
2 parents 0379a8d + 45eb4a8 commit 98ac8ac
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct(\OC\Files\Storage\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->lockingProvider = \OC::$server->get(ILockingProvider::class);
$this->connection = \OC::$server->get(IDBConnection::class);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Utils/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -100,7 +101,7 @@ public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInte
$this->dispatcher = $dispatcher;
$this->logger = $logger;
// when DB locking is used, no DB transactions will be used
$this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider);
$this->useTransaction = !(\OC::$server->get(ILockingProvider::class) instanceof DBLockingProvider);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function __construct(string $root = '') {
}

$this->fakeRoot = $root;
$this->lockingProvider = \OC::$server->getLockingProvider();
$this->lockingProvider = \OC::$server->get(ILockingProvider::class);
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
$this->userManager = \OC::$server->getUserManager();
$this->logger = \OC::$server->get(LoggerInterface::class);
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Files/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ public function testWriteToReadUnlockableFile($rootPath, $pathPrefix) {
* Test that locks are on mount point paths instead of mount root
*/
public function testLockLocalMountPointPathInsteadOfStorageRoot() {
$lockingProvider = \OC::$server->getLockingProvider();
$lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
Expand Down Expand Up @@ -1418,7 +1418,7 @@ public function testLockLocalMountPointPathInsteadOfStorageRoot() {
* Test that locks are on mount point paths and also mount root when requested
*/
public function testLockStorageRootButNotLocalMountPoint() {
$lockingProvider = \OC::$server->getLockingProvider();
$lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
Expand Down Expand Up @@ -1448,7 +1448,7 @@ public function testLockStorageRootButNotLocalMountPoint() {
* Test that locks are on mount point paths and also mount root when requested
*/
public function testLockMountPointPathFailReleasesBoth() {
$lockingProvider = \OC::$server->getLockingProvider();
$lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
Expand Down
5 changes: 3 additions & 2 deletions tests/lib/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Lock\ILockingProvider;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -197,7 +198,7 @@ protected function tearDown(): void {
// further cleanup
$hookExceptions = \OC_Hook::$thrownExceptions;
\OC_Hook::$thrownExceptions = [];
\OC::$server->getLockingProvider()->releaseAll();
\OC::$server->get(ILockingProvider::class)->releaseAll();
if (!empty($hookExceptions)) {
throw $hookExceptions[0];
}
Expand Down Expand Up @@ -418,7 +419,7 @@ protected static function tearDownAfterClassCleanStrayHooks() {
* Clean up the list of locks
*/
protected static function tearDownAfterClassCleanStrayLocks() {
\OC::$server->getLockingProvider()->releaseAll();
\OC::$server->get(ILockingProvider::class)->releaseAll();
}

/**
Expand Down

0 comments on commit 98ac8ac

Please sign in to comment.