Server IP : 184.154.167.98 / Your IP : 52.14.66.242 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/tampico1900/lib/private/Files/Lock/ |
Upload File : |
<?php namespace OC\Files\Lock; use OCP\Files\Lock\ILock; use OCP\Files\Lock\ILockManager; use OCP\Files\Lock\ILockProvider; use OCP\Files\Lock\LockContext; use OCP\PreConditionNotMetException; class LockManager implements ILockManager { private ?ILockProvider $lockProvider = null; private ?LockContext $lockInScope = null; public function registerLockProvider(ILockProvider $lockProvider): void { if ($this->lockProvider) { throw new PreConditionNotMetException('There is already a registered lock provider'); } $this->lockProvider = $lockProvider; } public function isLockProviderAvailable(): bool { return $this->lockProvider !== null; } public function runInScope(LockContext $lock, callable $callback): void { if (!$this->lockProvider) { $callback(); return; } if ($this->lockInScope) { throw new PreConditionNotMetException('Could not obtain lock scope as already in use by ' . $this->lockInScope); } try { $this->lockInScope = $lock; $callback(); } finally { $this->lockInScope = null; } } public function getLockInScope(): ?LockContext { return $this->lockInScope; } public function getLocks(int $fileId): array { if (!$this->lockProvider) { throw new PreConditionNotMetException('No lock provider available'); } return $this->lockProvider->getLocks($fileId); } public function lock(LockContext $lockInfo): ILock { if (!$this->lockProvider) { throw new PreConditionNotMetException('No lock provider available'); } return $this->lockProvider->lock($lockInfo); } public function unlock(LockContext $lockInfo): void { if (!$this->lockProvider) { throw new PreConditionNotMetException('No lock provider available'); } $this->lockProvider->unlock($lockInfo); } }