Commit aece33e
fix(encryption): Correctly report size for zero-byte encrypted files
This fixes a bug where zero-byte encrypted files were incorrectly
reported as 8192 bytes (the encryption header size) instead of 0 bytes.
Root Cause:
- CacheEntry::getUnencryptedSize() and FileInfo::getSize() checked
if unencrypted_size > 0 before using it
- For zero-byte files, this condition fails (0 > 0 is false)
- Falls back to encrypted size (8192 bytes) instead of 0
Impact:
- Zero-byte encrypted files showed wrong size in UI and API
- Database stored correct unencrypted_size=0, but getSize() returned 8192
- Affected quota calculations, file listings, and size comparisons
Fix:
- Remove the > 0 check from both methods
- Now checks only isset() to distinguish between missing and zero values
- Zero-byte files correctly report size as 0
Testing:
- Added zero-byte files to all encryption test scenarios
- testSizeConsistencyAcrossSources with 0 bytes - PASS
- testEncryptedFileRoundTrip with 0 bytes - PASS
- testEncryptedFileIntegrity with 0 bytes - PASS
- All 26 tests passing including edge cases
Files Modified:
- lib/private/Files/Cache/CacheEntry.php - getUnencryptedSize()
- lib/private/Files/FileInfo.php - getSize()
- tests/lib/Files/ObjectStore/S3EncryptionTest.php - Added 0-byte test cases
Signed-off-by: Claude Sonnet 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Signed-off-by: Stephen Cuppett <[email protected]>1 parent 8541b9d commit aece33e
File tree
3 files changed
+10
-15
lines changed- lib/private/Files
- Cache
- tests/lib/Files/ObjectStore
3 files changed
+10
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
229 | 235 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 236 | + | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | 240 | | |
246 | 241 | | |
247 | 242 | | |
| |||
0 commit comments