diff options
author | Robin Appelman <robin@icewind.nl> | 2023-11-20 17:30:04 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-11-20 17:31:10 +0100 |
commit | ee8942c62bfd8a93815c531e9a2dc32e83c175f5 (patch) | |
tree | 8aa7fcd7075dfab2d8f2c9c2c3e6e67fd43c69b9 | |
parent | 37c4da8fd3e9760205e0c9fa916c86493bc949df (diff) | |
download | nextcloud-server-obj-delete-not-found-20.tar.gz nextcloud-server-obj-delete-not-found-20.zip |
raise proper error when s3 object doesn't existobj-delete-not-found-20
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/ObjectStore/S3ObjectTrait.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 4d6ac3608df..55626be42c5 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -33,6 +33,7 @@ use Aws\S3\ObjectUploader; use Aws\S3\S3Client; use Icewind\Streams\CallbackWrapper; use OC\Files\Stream\SeekableHttpStream; +use OCP\Files\NotFoundException; trait S3ObjectTrait { /** @@ -71,7 +72,11 @@ trait S3ObjectTrait { ]; $context = stream_context_create($opts); - return fopen($request->getUri(), 'r', false, $context); + $fh = fopen($request->getUri(), 'r', false, $context); + if (!$fh && isset($http_response_header[0]) && str_contains($http_response_header[0], '404')) { + throw new NotFoundException("object $urn not found in object store bucket " . $this->getBucket()); + } + return $fh; }); } |