mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #50763 from nextcloud/backport/50498/stable31
[stable31] Don't rethrow a type error
This commit is contained in:
commit
2a76114134
3 changed files with 18 additions and 28 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue