mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-09 07:25:44 +02:00
- Archive card: fixed a cache bug, where wrong cover image was shown
This commit is contained in:
@@ -860,7 +860,17 @@ async def get_thumbnail(archive_id: int, db: AsyncSession = Depends(get_db)):
|
||||
if not thumb_path.exists():
|
||||
raise HTTPException(404, "Thumbnail file not found")
|
||||
|
||||
return FileResponse(path=thumb_path, media_type="image/png")
|
||||
# Use file modification time as ETag to bust cache
|
||||
mtime = int(thumb_path.stat().st_mtime)
|
||||
|
||||
return FileResponse(
|
||||
path=thumb_path,
|
||||
media_type="image/png",
|
||||
headers={
|
||||
"Cache-Control": "no-cache, must-revalidate",
|
||||
"ETag": f'"{mtime}"',
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{archive_id}/timelapse")
|
||||
|
||||
@@ -1426,7 +1426,7 @@ export const api = {
|
||||
request<{ updated: number; errors: Array<{ id: number; error: string }> }>('/archives/backfill-hashes', {
|
||||
method: 'POST',
|
||||
}),
|
||||
getArchiveThumbnail: (id: number) => `${API_BASE}/archives/${id}/thumbnail`,
|
||||
getArchiveThumbnail: (id: number) => `${API_BASE}/archives/${id}/thumbnail?v=${Date.now()}`,
|
||||
getArchiveDownload: (id: number) => `${API_BASE}/archives/${id}/download`,
|
||||
getArchiveGcode: (id: number) => `${API_BASE}/archives/${id}/gcode`,
|
||||
getArchiveTimelapse: (id: number) => `${API_BASE}/archives/${id}/timelapse?v=${Date.now()}`,
|
||||
|
||||
@@ -124,7 +124,7 @@ function ArchiveGrid({ archives }: { archives: Archive[] }) {
|
||||
>
|
||||
{archive.thumbnail_path ? (
|
||||
<img
|
||||
src={`/api/v1/archives/${archive.id}/thumbnail`}
|
||||
src={api.getArchiveThumbnail(archive.id)}
|
||||
alt={archive.print_name || 'Print'}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
|
||||
@@ -416,7 +416,7 @@ function ProjectCard({ project, onClick, onEdit, onDelete }: ProjectCardProps) {
|
||||
>
|
||||
{archive.thumbnail_path ? (
|
||||
<img
|
||||
src={`/api/v1/archives/${archive.id}/thumbnail`}
|
||||
src={api.getArchiveThumbnail(archive.id)}
|
||||
alt={archive.print_name || ''}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
<!-- Splash screens for iOS -->
|
||||
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
|
||||
<script type="module" crossorigin src="/assets/index-BGnYjiV-.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-Bh0qWzko.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CiDcmh7W.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user