From 481cc19afeb1151f442ea497e63c8fa0232e0614 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 5 Apr 2026 03:39:56 +0000 Subject: [PATCH] fix: address CodeRabbit review - strict comparison and test assertions Use strict !== in View/Get.php for consistency with Download/Get.php. Add accept-ranges and content-length assertions for single-byte probe and large-file download tests. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Platform/Modules/Storage/Http/Buckets/Files/View/Get.php | 2 +- tests/e2e/Services/Storage/StorageBase.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php index 3d655ac2ef..7e13de34ca 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/View/Get.php @@ -144,7 +144,7 @@ class Get extends Action $end = min(($start + APP_STORAGE_READ_BUFFER - 1), ($size - 1)); } - if ($unit != 'bytes' || $start > $end || $end >= $size) { + if ($unit !== 'bytes' || $start > $end || $end >= $size) { throw new Exception(Exception::STORAGE_INVALID_RANGE); } diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index a2dcd6a126..552173899d 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -780,6 +780,7 @@ trait StorageBase $this->assertEquals(206, $file51a['headers']['status-code']); $this->assertEquals('1', $file51a['headers']['content-length']); + $this->assertEquals('bytes', $file51a['headers']['accept-ranges']); // Test ranged download - with invalid range $file52 = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $data['fileId'] . '/download', array_merge([ @@ -863,6 +864,8 @@ trait StorageBase $this->assertEquals(200, $file7['headers']['status-code']); $this->assertEquals('attachment; filename="large-file.mp4"', $file7['headers']['content-disposition']); $this->assertEquals('video/mp4', $file7['headers']['content-type']); + $this->assertEquals('bytes', $file7['headers']['accept-ranges']); + $this->assertNotEmpty($file7['headers']['content-length']); $this->assertNotEmpty($fileData); $this->assertEquals(md5_file(realpath(__DIR__ . '/../../../resources/disk-a/large-file.mp4')), md5($fileData)); // validate the file is downloaded correctly