summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-02-18 16:41:10 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-02-28 09:38:11 +0000
commit25b4c7dccdf6b533212798dfc02089164811d177 (patch)
tree5578bbe35596a5ea49ab48dbc346b3745a91b654 /apps
parent52163b49054e7e782d955840e9f3ab4d731745f7 (diff)
downloadnextcloud-server-25b4c7dccdf6b533212798dfc02089164811d177.tar.gz
nextcloud-server-25b4c7dccdf6b533212798dfc02089164811d177.zip
fix(dav): Handle end of stream in `File::put`backport/50881/stable31
If the stream is aborted and the callback wrapper returns false (or null as it happened in some cases), we should not try to write to the storage but abort the operation. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php27
1 files changed, 11 insertions, 16 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index d6bd6369c9d..67b562a6221 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -13,7 +13,6 @@ use OC\Files\Filesystem;
use OC\Files\Stream\HashWrapper;
use OC\Files\View;
use OCA\DAV\AppInfo\Application;
-use OCA\DAV\Connector\Sabre\Exception\BadGateway;
use OCA\DAV\Connector\Sabre\Exception\EntityTooLarge;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden as DAVForbiddenException;
@@ -207,21 +206,17 @@ class File extends Node implements IFile {
$isEOF = feof($stream);
});
- $result = true;
- $count = -1;
- try {
- $count = $partStorage->writeStream($internalPartPath, $wrappedData);
- } catch (GenericFileException $e) {
- $result = false;
- } catch (BadGateway $e) {
- throw $e;
- }
-
-
- if ($result === false) {
- $result = $isEOF;
- if (is_resource($wrappedData)) {
- $result = feof($wrappedData);
+ $result = is_resource($wrappedData);
+ if ($result) {
+ $count = -1;
+ try {
+ /** @var IWriteStreamStorage $partStorage */
+ $count = $partStorage->writeStream($internalPartPath, $wrappedData);
+ } catch (GenericFileException) {
+ $result = $isEOF;
+ if (is_resource($wrappedData)) {
+ $result = feof($wrappedData);
+ }
}
}
} else {