pass the existing locks info when making locked exception with absolute paths
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
a216694e66
commit
a480feaf35
|
@ -262,7 +262,7 @@ class File extends Node implements IFile {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE);
|
$this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE);
|
||||||
} catch (LockedException $e) {
|
} catch (LockedException $ex) {
|
||||||
if ($needsPartFile) {
|
if ($needsPartFile) {
|
||||||
$partStorage->unlink($internalPartPath);
|
$partStorage->unlink($internalPartPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1944,7 +1944,8 @@ class View {
|
||||||
// rethrow with the a human-readable path
|
// rethrow with the a human-readable path
|
||||||
throw new \OCP\Lock\LockedException(
|
throw new \OCP\Lock\LockedException(
|
||||||
$this->getPathRelativeToFiles($absolutePath),
|
$this->getPathRelativeToFiles($absolutePath),
|
||||||
$e
|
$e,
|
||||||
|
$e->getExistingLock()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1986,12 +1987,14 @@ class View {
|
||||||
// rethrow with the a human-readable path
|
// rethrow with the a human-readable path
|
||||||
throw new \OCP\Lock\LockedException(
|
throw new \OCP\Lock\LockedException(
|
||||||
$this->getPathRelativeToFiles($absolutePath),
|
$this->getPathRelativeToFiles($absolutePath),
|
||||||
$e
|
$e,
|
||||||
|
$e->getExistingLock()
|
||||||
);
|
);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $ex) {
|
||||||
throw new \OCP\Lock\LockedException(
|
throw new \OCP\Lock\LockedException(
|
||||||
$absolutePath,
|
$absolutePath,
|
||||||
$e
|
$ex,
|
||||||
|
$e->getExistingLock()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ class LockedException extends \Exception {
|
||||||
*/
|
*/
|
||||||
private $path;
|
private $path;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $existingLock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LockedException constructor.
|
* LockedException constructor.
|
||||||
*
|
*
|
||||||
|
@ -51,6 +54,7 @@ class LockedException extends \Exception {
|
||||||
*/
|
*/
|
||||||
public function __construct(string $path, \Exception $previous = null, string $existingLock = null) {
|
public function __construct(string $path, \Exception $previous = null, string $existingLock = null) {
|
||||||
$message = '"' . $path . '" is locked';
|
$message = '"' . $path . '" is locked';
|
||||||
|
$this->existingLock = $existingLock;
|
||||||
if ($existingLock) {
|
if ($existingLock) {
|
||||||
$message .= ', existing lock on file: ' . $existingLock;
|
$message .= ', existing lock on file: ' . $existingLock;
|
||||||
}
|
}
|
||||||
|
@ -65,4 +69,12 @@ class LockedException extends \Exception {
|
||||||
public function getPath(): string {
|
public function getPath(): string {
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @since 19.0.0
|
||||||
|
*/
|
||||||
|
public function getExistingLock(): ?string {
|
||||||
|
return $this->existingLock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue