Repository navigation
fix(storage): refuse reads of files whose upload is not complete - #14876
Conversation
|
Review complete. No issues found — approved ✅. This change makes the four file-serving endpoints treat a file as not found until its final chunk has been uploaded and joined, preventing clients from reading a partially assembled file. The check mirrors the existing
No issues were identified in the reviewed code paths. Reviewed commit: 80f45cc |
🔵 Tier A · Mergeable after minor fixes
The Storage download, view, preview, and push routes now check upload chunk counters before accessing file content. Files remain unavailable through these routes until all chunks are uploaded and finalization has completed.
Fix with agent prompt### Issue 1
src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php:122
**Cover pending-file reads in Storage E2E tests**
The Storage E2E suite exercises partial uploads and completed-file reads, but does not attempt these content routes against a pending file. Add coverage that leaves a chunk outstanding and verifies the download, view, preview, and push routes (including token access) return `storage_file_not_found`, so this completion gate cannot regress unnoticed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 4
Reviewed |
|
|
||
| if ($file->isEmpty()) { | ||
| // A file stays incomplete until its final chunk is joined and scanned. | ||
| if ($file->isEmpty() || $file->getAttribute('chunksUploaded', 0) < $file->getAttribute('chunksTotal', 1)) { |
There was a problem hiding this comment.
Cover pending-file reads in Storage E2E tests
The Storage E2E suite exercises partial uploads and completed-file reads, but does not attempt these content routes against a pending file. Add coverage that leaves a chunk outstanding and verifies the download, view, preview, and push routes (including token access) return storage_file_not_found, so this completion gate cannot regress unnoticed.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Download/Get.php
Line: 122
Comment:
**Cover pending-file reads in Storage E2E tests**
The Storage E2E suite exercises partial uploads and completed-file reads, but does not attempt these content routes against a pending file. Add coverage that leaves a chunk outstanding and verifies the download, view, preview, and push routes (including token access) return `storage_file_not_found`, so this completion gate cannot regress unnoticed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
View, download, preview and push served a file before its final chunk was joined and scanned. They now answer file not found until every chunk is uploaded. (cherry picked from commit 73b71a6)
…read fix(storage): refuse reads of files whose upload is not complete (cherry picked from commit 73b71a6)
1.9.10 refuses reads of incomplete uploads (#14876); a preview cached before the upgrade would otherwise still be served on a cache hit.
Download, view, preview and push file routes (including token access, which goes through the same routes) now return
storage_file_not_foundwhilechunksUploaded < chunksTotal, i.e. until the final chunk has been joined and scanned. No schema change.Details are tracked internally.
Tested: PHP syntax check on the touched files; CI e2e for Storage.