]> source.dussan.org Git - nextcloud-server.git/commitdiff
pass the existing locks info when making locked exception with absolute paths 19746/head
authorRobin Appelman <robin@icewind.nl>
Mon, 2 Mar 2020 16:47:48 +0000 (17:47 +0100)
committerRobin Appelman <robin@icewind.nl>
Mon, 2 Mar 2020 18:29:44 +0000 (19:29 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/dav/lib/Connector/Sabre/File.php
lib/private/Files/View.php
lib/public/Lock/LockedException.php

index a1f5e2fe876f258f58e45190b849e66a2f3c3ccd..098961ce1309c49a80c2d68ca935f9a51fc18180 100644 (file)
@@ -263,7 +263,7 @@ class File extends Node implements IFile {
 
                                        try {
                                                $this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE);
-                                       } catch (LockedException $e) {
+                                       } catch (LockedException $ex) {
                                                if ($needsPartFile) {
                                                        $partStorage->unlink($internalPartPath);
                                                }
index 2c01c112ad4ee3198b9f8315b52e62319e0a10a2..90ac1e1988d360ddbdaf8f024b781d33936b5e92 100644 (file)
@@ -1946,7 +1946,8 @@ class View {
                                // rethrow with the a human-readable path
                                throw new LockedException(
                                        $this->getPathRelativeToFiles($absolutePath),
-                                       $e
+                                       $e,
+                                       $e->getExistingLock()
                                );
                        }
                }
@@ -1988,12 +1989,14 @@ class View {
                                        // rethrow with the a human-readable path
                                        throw new LockedException(
                                                $this->getPathRelativeToFiles($absolutePath),
-                                               $e
+                                               $e,
+                                               $e->getExistingLock()
                                        );
-                               } catch (\InvalidArgumentException $e) {
+                               } catch (\InvalidArgumentException $ex) {
                                        throw new LockedException(
                                                $absolutePath,
-                                               $e
+                                               $ex,
+                                               $e->getExistingLock()
                                        );
                                }
                        }
index 99205b54d24146f2a1ed339aa82da611fe88af92..582157010ccb5d3d8814b2e1ea0abb373f7776ca 100644 (file)
@@ -44,6 +44,9 @@ class LockedException extends \Exception {
         */
        private $path;
 
+       /** @var string|null */
+       private $existingLock;
+
        /**
         * LockedException constructor.
         *
@@ -54,6 +57,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;
                }
@@ -68,4 +72,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;
+       }
 }