From 437c0b55a625ce3c2c6a81740fda8cb7a0bf1998 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 22 May 2015 13:43:44 +0200 Subject: [PATCH] unlock source file when we cant lock the target in a rename --- lib/private/files/view.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/private/files/view.php b/lib/private/files/view.php index db904e57cb..d6cc62dff2 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -49,6 +49,7 @@ use OCP\Files\InvalidCharacterInPathException; use OCP\Files\InvalidPathException; use OCP\Files\ReservedWordException; use OCP\Lock\ILockingProvider; +use OCP\Lock\LockedException; /** * Class to provide access to ownCloud filesystem via a "view", and methods for @@ -638,7 +639,12 @@ class View { $internalPath2 = $mount2->getInternalPath($absolutePath2); $this->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE); - $this->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE); + try { + $this->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE); + } catch (LockedException $e) { + $this->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE); + throw $e; + } if ($internalPath1 === '' and $mount1 instanceof MoveableMount) { if ($this->isTargetAllowed($absolutePath2)) {