mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-17 20:33:54 +09:00
Updates to vendors etc
This commit is contained in:
27
vendor/symfony/console/Command/LockableTrait.php
vendored
27
vendor/symfony/console/Command/LockableTrait.php
vendored
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\LockInterface;
|
||||
@@ -26,6 +27,8 @@ trait LockableTrait
|
||||
{
|
||||
private ?LockInterface $lock = null;
|
||||
|
||||
private ?LockFactory $lockFactory = null;
|
||||
|
||||
/**
|
||||
* Locks a command.
|
||||
*/
|
||||
@@ -39,13 +42,27 @@ trait LockableTrait
|
||||
throw new LogicException('A lock is already in place.');
|
||||
}
|
||||
|
||||
if (SemaphoreStore::isSupported()) {
|
||||
$store = new SemaphoreStore();
|
||||
} else {
|
||||
$store = new FlockStore();
|
||||
if (null === $this->lockFactory) {
|
||||
if (SemaphoreStore::isSupported()) {
|
||||
$store = new SemaphoreStore();
|
||||
} else {
|
||||
$store = new FlockStore();
|
||||
}
|
||||
|
||||
$this->lockFactory = new LockFactory($store);
|
||||
}
|
||||
|
||||
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
|
||||
if (!$name) {
|
||||
if ($this instanceof Command) {
|
||||
$name = $this->getName();
|
||||
} elseif ($attribute = (new \ReflectionClass($this::class))->getAttributes(AsCommand::class)) {
|
||||
$name = $attribute[0]->newInstance()->name;
|
||||
} else {
|
||||
throw new LogicException(\sprintf('Lock name missing: provide it via "%s()", #[AsCommand] attribute, or by extending Command class.', __METHOD__));
|
||||
}
|
||||
}
|
||||
|
||||
$this->lock = $this->lockFactory->createLock($name);
|
||||
if (!$this->lock->acquire($blocking)) {
|
||||
$this->lock = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user