| @@ 64-66 (lines=3) @@ | ||
| 61 | */ |
|
| 62 | protected function markAcquire(string $path, int $type) { |
|
| 63 | if ($type === self::LOCK_SHARED) { |
|
| 64 | if (!isset($this->acquiredLocks['shared'][$path])) { |
|
| 65 | $this->acquiredLocks['shared'][$path] = 0; |
|
| 66 | } |
|
| 67 | $this->acquiredLocks['shared'][$path]++; |
|
| 68 | } else { |
|
| 69 | $this->acquiredLocks['exclusive'][$path] = true; |
|
| @@ 83-85 (lines=3) @@ | ||
| 80 | if ($type === self::LOCK_SHARED) { |
|
| 81 | if (isset($this->acquiredLocks['shared'][$path]) and $this->acquiredLocks['shared'][$path] > 0) { |
|
| 82 | $this->acquiredLocks['shared'][$path]--; |
|
| 83 | if ($this->acquiredLocks['shared'][$path] === 0) { |
|
| 84 | unset($this->acquiredLocks['shared'][$path]); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | } else if ($type === self::LOCK_EXCLUSIVE) { |
|
| 88 | unset($this->acquiredLocks['exclusive'][$path]); |
|
| @@ 101-103 (lines=3) @@ | ||
| 98 | protected function markChange(string $path, int $targetType) { |
|
| 99 | if ($targetType === self::LOCK_SHARED) { |
|
| 100 | unset($this->acquiredLocks['exclusive'][$path]); |
|
| 101 | if (!isset($this->acquiredLocks['shared'][$path])) { |
|
| 102 | $this->acquiredLocks['shared'][$path] = 0; |
|
| 103 | } |
|
| 104 | $this->acquiredLocks['shared'][$path]++; |
|
| 105 | } else if ($targetType === self::LOCK_EXCLUSIVE) { |
|
| 106 | $this->acquiredLocks['exclusive'][$path] = true; |
|
| @@ 249-251 (lines=3) @@ | ||
| 246 | ); |
|
| 247 | } else { |
|
| 248 | // since we only keep one shared lock in the db we need to check if we have more then one shared lock locally manually |
|
| 249 | if (isset($this->acquiredLocks['shared'][$path]) && $this->acquiredLocks['shared'][$path] > 1) { |
|
| 250 | throw new LockedException($path); |
|
| 251 | } |
|
| 252 | $result = $this->connection->executeUpdate( |
|
| 253 | 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 1', |
|
| 254 | [$expire, $path] |
|