diff options
author | Daniel <mail@danielkesselberg.de> | 2025-02-11 17:28:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-11 17:28:44 +0100 |
commit | 90a1aea5747e7085ea8988ff8602b6d02c2f59c8 (patch) | |
tree | f1ec088d23e23c912b3259767b0f06be2e65555f | |
parent | 53749e06fc3fe3a3de3cb4f9e84ef3c6be9bf648 (diff) | |
parent | 4978cd3c2107f55e7f65d5aaf6e500318e9ef16a (diff) | |
download | nextcloud-server-90a1aea5747e7085ea8988ff8602b6d02c2f59c8.tar.gz nextcloud-server-90a1aea5747e7085ea8988ff8602b6d02c2f59c8.zip |
Merge pull request #50498 from nextcloud/bug/48678/restore-dav-error-response-2
Don't rethrow a type error
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Directory.php | 4 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Server.php | 18 | ||||
-rw-r--r-- | lib/private/Files/View.php | 24 |
3 files changed, 18 insertions, 28 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index ebef7f91ee0..7215723803f 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -111,11 +111,11 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot // only allow 1 process to upload a file at once but still allow reading the file while writing the part file $node->acquireLock(ILockingProvider::LOCK_SHARED); - $this->fileView->lockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE); + $this->fileView->lockFile($this->path . '/' . $name . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE); $result = $node->put($data); - $this->fileView->unlockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE); + $this->fileView->unlockFile($this->path . '/' . $name . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE); $node->releaseLock(ILockingProvider::LOCK_SHARED); return $result; } catch (StorageNotAvailableException $e) { diff --git a/apps/dav/lib/Connector/Sabre/Server.php b/apps/dav/lib/Connector/Sabre/Server.php index a7314d812dc..f3bfac1d6e0 100644 --- a/apps/dav/lib/Connector/Sabre/Server.php +++ b/apps/dav/lib/Connector/Sabre/Server.php @@ -9,6 +9,7 @@ namespace OCA\DAV\Connector\Sabre; use Sabre\DAV\Exception; use Sabre\DAV\Version; +use TypeError; /** * Class \OCA\DAV\Connector\Sabre\Server @@ -47,20 +48,17 @@ class Server extends \Sabre\DAV\Server { $this->httpRequest->setBaseUrl($this->getBaseUri()); $this->invokeMethod($this->httpRequest, $this->httpResponse); } catch (\Throwable $e) { - if ($e instanceof \TypeError) { + try { + $this->emit('exception', [$e]); + } catch (\Exception) { + } + + if ($e instanceof TypeError) { /* * The TypeError includes the file path where the error occurred, * potentially revealing the installation directory. - * - * By re-throwing the exception, we ensure that the - * default exception handler processes it. */ - throw $e; - } - - try { - $this->emit('exception', [$e]); - } catch (\Exception $ignore) { + $e = new TypeError('A type error occurred. For more details, please refer to the logs, which provide additional context about the type error.'); } $DOM = new \DOMDocument('1.0', 'utf-8'); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 5e09ce69fb2..fea1f64707b 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -2062,9 +2062,9 @@ class View { ); } } catch (LockedException $e) { - // rethrow with the a human-readable path + // rethrow with the human-readable path throw new LockedException( - $this->getPathRelativeToFiles($absolutePath), + $path, $e, $e->getExistingLock() ); @@ -2102,20 +2102,12 @@ class View { ); } } catch (LockedException $e) { - try { - // rethrow with the a human-readable path - throw new LockedException( - $this->getPathRelativeToFiles($absolutePath), - $e, - $e->getExistingLock() - ); - } catch (\InvalidArgumentException $ex) { - throw new LockedException( - $absolutePath, - $ex, - $e->getExistingLock() - ); - } + // rethrow with the a human-readable path + throw new LockedException( + $path, + $e, + $e->getExistingLock() + ); } return true; |