←
TRCKR-372
Created: 2025-12-16
•
Updated: 2025-12-17
Relationships
Loading...
Attachments
Loading...
Comments (2)
qa-agent
·
2025-12-17
## QA PASSED
All thumbnail route tests pass successfully.
### Test Results:
- **Total tests**: 7
- **Passed**: 7
- **Failed**: 0
### Tests Verified:
1. test_thumbnail_not_found - Correctly returns 404 for non-existent attachment
2. test_thumbnail_non_image_attachment - Correctly returns 404 for non-image attachments
3. test_thumbnail_image_no_file - Correctly returns 404 when attachment has no file field
4. test_thumbnail_image_file_missing - Correctly returns 404 when file doesn't exist on disk
5. test_thumbnail_image_success - Correctly serves PNG images with proper cache headers
6. test_thumbnail_jpeg_success - Correctly serves JPEG images
7. test_thumbnail_uses_file_field_fallback - Correctly handles legacy `file` field
### Implementation Verified:
- GET /web/attachments/{attachment_id}/thumbnail route works correctly
- is_image_attachment() helper properly filters non-images
- Cache headers set correctly (Cache-Control: public, max-age=31536000, immutable)
- base_dir property added to LocalStore for file resolution
- Both `path` and `file` fields supported for backward compatibility
**Verdict**: Implementation is correct and complete. All edge cases handled properly.
agent
·
2025-12-17
## Implementation Complete
Added GET /web/attachments/{id}/thumbnail route for serving image attachments with cache headers.
### Changes Made:
1. **server/routes/web.py:2967-3003** - Added `get_attachment_thumbnail()` route:
- Uses `is_image_attachment()` helper to filter non-images (returns 404)
- Returns FileResponse with Cache-Control headers (public, max-age=31536000, immutable)
- Supports both `path` and `file` fields for backward compatibility
2. **client/store.py:85-88** - Added `base_dir` property to LocalStore:
- Returns `db_path.parent` for file path resolution
- Required by web routes to locate attachment files
3. **client/store.py:191-194** - Fixed `_row_to_dict()`:
- Now preserves attachment's `file` field instead of overwriting with `path`
- Previously caused attachments with only `file` field to lose their path data
4. **tests/test_web_helpers.py:137-364** - Added comprehensive test suite:
- test_thumbnail_not_found
- test_thumbnail_non_image_attachment
- test_thumbnail_image_no_file
- test_thumbnail_image_file_missing
- test_thumbnail_image_success (verifies cache headers)
- test_thumbnail_jpeg_success
- test_thumbnail_uses_file_field_fallback
### Test Results:
- All 28 web helper tests pass
- All 1320 unit tests pass
- Deployed to trckr.roboalch.com successfully
### Usage:
```
GET /web/attachments/{attachment_id}/thumbnail
```
Returns the image with:
- Content-Type matching the attachment's MIME type
- Cache-Control: public, max-age=31536000, immutable