diff options
author | Robin Appelman <robin@icewind.nl> | 2020-06-30 18:10:42 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-06-30 18:10:42 +0200 |
commit | da2d4250446b6e2f921bd3de0420738881792bd3 (patch) | |
tree | 876c3a427de61033593de9e93a606654172fae79 /lib/private/Lock | |
parent | 26aa83890667202154ef086e27e769919fb56a47 (diff) | |
download | nextcloud-server-da2d4250446b6e2f921bd3de0420738881792bd3.tar.gz nextcloud-server-da2d4250446b6e2f921bd3de0420738881792bd3.zip |
add proper paths to locking exceptions
while some code paths do wrap the "raw" locking exception into one with a proper path, not all of them do
by adding the proper path to the original exception we ensure that we always have the usefull information in out logs
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Lock')
-rw-r--r-- | lib/private/Lock/DBLockingProvider.php | 4 | ||||
-rw-r--r-- | lib/private/Lock/MemcacheLockingProvider.php | 7 | ||||
-rw-r--r-- | lib/private/Lock/NoopLockingProvider.php | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index c32d7b4877a..f48bf57028f 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -180,7 +180,7 @@ class DBLockingProvider extends AbstractLockingProvider { * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE * @throws \OCP\Lock\LockedException */ - public function acquireLock(string $path, int $type) { + public function acquireLock(string $path, int $type, string $readablePath = null) { $expire = $this->getExpireTime(); if ($type === self::LOCK_SHARED) { if (!$this->isLocallyLocked($path)) { @@ -208,7 +208,7 @@ class DBLockingProvider extends AbstractLockingProvider { } } if ($result !== 1) { - throw new LockedException($path); + throw new LockedException($path, null, null, $readablePath); } $this->markAcquire($path, $type); } diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index 3d7510f43ff..c9dfcea3197 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -71,17 +71,18 @@ class MemcacheLockingProvider extends AbstractLockingProvider { /** * @param string $path * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE + * @param string $readablePath human readable path to use in error messages * @throws \OCP\Lock\LockedException */ - public function acquireLock(string $path, int $type) { + public function acquireLock(string $path, int $type, string $readablePath = null) { if ($type === self::LOCK_SHARED) { if (!$this->memcache->inc($path)) { - throw new LockedException($path, null, $this->getExistingLockForException($path)); + throw new LockedException($path, null, $this->getExistingLockForException($path), $readablePath); } } else { $this->memcache->add($path, 0); if (!$this->memcache->cas($path, 0, 'exclusive')) { - throw new LockedException($path, null, $this->getExistingLockForException($path)); + throw new LockedException($path, null, $this->getExistingLockForException($path), $readablePath); } } $this->setTTL($path); diff --git a/lib/private/Lock/NoopLockingProvider.php b/lib/private/Lock/NoopLockingProvider.php index 94612e22f53..4f38d5159b9 100644 --- a/lib/private/Lock/NoopLockingProvider.php +++ b/lib/private/Lock/NoopLockingProvider.php @@ -46,7 +46,7 @@ class NoopLockingProvider implements ILockingProvider { /** * {@inheritdoc} */ - public function acquireLock(string $path, int $type) { + public function acquireLock(string $path, int $type, string $readablePath = null) { // do nothing } |