diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 2d019b46b6..5701941891 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -262,7 +262,7 @@ class File extends Node implements IFile { try { $this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE); - } catch (LockedException $e) { + } catch (LockedException $ex) { if ($needsPartFile) { $partStorage->unlink($internalPartPath); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index c173cde2d2..a8a21e4346 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1944,7 +1944,8 @@ class View { // rethrow with the a human-readable path throw new \OCP\Lock\LockedException( $this->getPathRelativeToFiles($absolutePath), - $e + $e, + $e->getExistingLock() ); } } @@ -1986,12 +1987,14 @@ class View { // rethrow with the a human-readable path throw new \OCP\Lock\LockedException( $this->getPathRelativeToFiles($absolutePath), - $e + $e, + $e->getExistingLock() ); - } catch (\InvalidArgumentException $e) { + } catch (\InvalidArgumentException $ex) { throw new \OCP\Lock\LockedException( $absolutePath, - $e + $ex, + $e->getExistingLock() ); } } diff --git a/lib/public/Lock/LockedException.php b/lib/public/Lock/LockedException.php index b4038f8dd5..d9c94fd637 100644 --- a/lib/public/Lock/LockedException.php +++ b/lib/public/Lock/LockedException.php @@ -41,6 +41,9 @@ class LockedException extends \Exception { */ private $path; + /** @var string|null */ + private $existingLock; + /** * LockedException constructor. * @@ -51,6 +54,7 @@ class LockedException extends \Exception { */ public function __construct(string $path, \Exception $previous = null, string $existingLock = null) { $message = '"' . $path . '" is locked'; + $this->existingLock = $existingLock; if ($existingLock) { $message .= ', existing lock on file: ' . $existingLock; } @@ -65,4 +69,12 @@ class LockedException extends \Exception { public function getPath(): string { return $this->path; } + + /** + * @return string + * @since 19.0.0 + */ + public function getExistingLock(): ?string { + return $this->existingLock; + } }