Skip to content

Commit 504dba6

Browse files
tjelite1986claude
andcommitted
photo-gallery 0.3.2: cache-bust regenerated thumbnails
New media_version column appended as &v= to asset URLs; bumped on rotate and HEIF repair so immutable-cached derivatives refresh. Backported from elite-hub commit 945266b. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 91c7779 commit 504dba6

7 files changed

Lines changed: 21 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ All notable changes to the modules library are tracked here. Format loosely foll
1212
- `bookshelf` (0.1.0 → **0.2.0**) — reader and listing pages build cover/file URLs with `mediaToken()` instead of embedding the session JWT. Requires `authentication >= 0.3.0`.
1313
- `photo-gallery` (0.1.0 → **0.2.0**) — all client components (timeline, albums, smart albums, map, trips, tags, year-in-review, bulk download) build thumb/preview/file URLs with `mediaToken()` instead of embedding the session JWT. Requires `authentication >= 0.3.0`.
1414
- `photo-gallery` (0.2.0 → **0.2.1**) — lightbox info rows (filename, type, size, storage key, EXIF fields) gained copy-to-clipboard buttons with check-mark feedback, falling back to `execCommand` outside secure contexts. Backported from [elite-hub commit `efc9f30`](https://github.com/tjelite1986/elite-hub/commit/efc9f30).
15+
- `photo-gallery` (0.3.1 → **0.3.2**) — thumb/preview/file URLs now carry a `&v=<media_version>` cache-buster. The asset routes serve `Cache-Control: immutable` for a year, so regenerated derivatives (rotate, HEIF repair) kept showing stale in browsers; the new `media_version` column is bumped on every regeneration. Backported from [elite-hub commit `945266b`](https://github.com/tjelite1986/elite-hub/commit/945266b).
1516
- `photo-gallery` (0.3.0 → **0.3.1**) — fixed HEIC/HEIF photos decoding as a single zoomed-in 512px tile: ffmpeg/ffprobe can't handle tiled HEIF, so ingest and `makeImageThumb` now convert via libheif (`heif-convert`) first; thumbs, previews and stored dimensions all derive from the converted JPEG. New `POST /api/gallery/repair-heif` + "Repair HEIF previews" maintenance action regenerate already-ingested items. `libheif-tools` + `ffmpeg` added as documented system deps. Backported from [elite-hub commit `58bf32e`](https://github.com/tjelite1986/elite-hub/commit/58bf32e).
1617
- `photo-gallery` (0.2.1 → **0.3.0**) — capture dates are now parsed from filenames (WhatsApp `IMG-yyyymmdd-WA####`, Samsung/Android `yyyymmdd_hhmmss`, Pixel `PXL_…`, screenshots, Telegram/Signal, Dropbox, epoch-named files) via new `lib/filenameDate.ts` with strict validation. Ingest falls back EXIF → filename → mtime → now. New `POST /api/gallery/backfill-filename-dates` + "Fix dates from filenames" maintenance action re-date existing items; anything still carrying an EXIF date is left untouched. Backported from [elite-hub commit `aaac1b1`](https://github.com/tjelite1986/elite-hub/commit/aaac1b1).
1718

photo-gallery/components/GalleryClient.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,22 @@ function authHeaders() {
5656
return { Authorization: `Bearer ${authToken()}` };
5757
}
5858

59+
// The v param busts the browser's immutable cache when derived media is
60+
// regenerated (rotate, HEIF repair) — the storage key stays the same.
61+
function mediaVersion(item: GalleryItem) {
62+
return item.media_version ? `&v=${item.media_version}` : "";
63+
}
64+
5965
export function thumbUrl(item: GalleryItem) {
60-
return `/api/gallery/thumb/${item.storage_key}?t=${encodeURIComponent(mediaToken())}`;
66+
return `/api/gallery/thumb/${item.storage_key}?t=${encodeURIComponent(mediaToken())}${mediaVersion(item)}`;
6167
}
6268

6369
export function previewUrl(item: GalleryItem) {
64-
return `/api/gallery/preview/${item.storage_key}?t=${encodeURIComponent(mediaToken())}`;
70+
return `/api/gallery/preview/${item.storage_key}?t=${encodeURIComponent(mediaToken())}${mediaVersion(item)}`;
6571
}
6672

6773
export function originalUrl(item: GalleryItem) {
68-
return `/api/gallery/file/${item.storage_key}?t=${encodeURIComponent(mediaToken())}`;
74+
return `/api/gallery/file/${item.storage_key}?t=${encodeURIComponent(mediaToken())}${mediaVersion(item)}`;
6975
}
7076

7177
function fileUrlForLightbox(item: GalleryItem, variant: "preview" | "file") {

photo-gallery/db/schema.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ ALTER TABLE gallery_items ADD COLUMN description TEXT;
8282
ALTER TABLE gallery_items ADD COLUMN latitude REAL;
8383
ALTER TABLE gallery_items ADD COLUMN longitude REAL;
8484
ALTER TABLE gallery_items ADD COLUMN location_name TEXT;
85+
-- Cache-busting version for derived media (thumb/preview); bumped on rotate
86+
-- and HEIF repair so immutable-cached URLs change.
87+
ALTER TABLE gallery_items ADD COLUMN media_version INTEGER NOT NULL DEFAULT 0;
8588
CREATE INDEX IF NOT EXISTS idx_gallery_items_geo ON gallery_items(latitude, longitude);
8689
CREATE TABLE IF NOT EXISTS gallery_trips (
8790
id INTEGER PRIMARY KEY AUTOINCREMENT,

photo-gallery/lib/gallery-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface GalleryItem {
2424
longitude: number | null;
2525
location_name: string | null;
2626
rating: number;
27+
media_version?: number;
2728
tag_count?: number;
2829
}
2930

photo-gallery/lib/gallery.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface GalleryItem {
5050
longitude: number | null;
5151
location_name: string | null;
5252
rating: number;
53+
media_version?: number;
5354
tag_count?: number;
5455
}
5556

@@ -689,7 +690,8 @@ export async function rotateItem(
689690
const stat = fs.statSync(orig);
690691
const db = getDb();
691692
db.prepare(
692-
"UPDATE gallery_items SET width = ?, height = ?, size_bytes = ? WHERE id = ? AND user_id = ?",
693+
`UPDATE gallery_items SET width = ?, height = ?, size_bytes = ?,
694+
media_version = media_version + 1 WHERE id = ? AND user_id = ?`,
693695
).run(result.width ?? null, result.height ?? null, stat.size, id, userId);
694696
return getItem(userId, id);
695697
}
@@ -742,7 +744,8 @@ export async function repairHeifMedia(userId: number): Promise<{
742744
);
743745
db.prepare(
744746
`UPDATE gallery_items SET width = ?, height = ?,
745-
thumbnail_ready = ?, preview_ready = ? WHERE id = ? AND user_id = ?`,
747+
thumbnail_ready = ?, preview_ready = ?,
748+
media_version = media_version + 1 WHERE id = ? AND user_id = ?`,
746749
).run(
747750
probed.width ?? null,
748751
probed.height ?? null,

photo-gallery/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "photo-gallery",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Google-Photos-style library: timeline, albums, smart albums, map view, auto-trip detection, year-in-review, tag browser, share links, EXIF + geotag, content-hash dedup",
55
"category": "media",
66
"framework": {

registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
"description": "Google-Photos-style library: timeline, albums, smart albums, map view, auto-trip detection, year-in-review, tag browser, share links, EXIF + geotag, content-hash dedup",
385385
"category": "media",
386386
"tags": ["gallery", "photos", "albums", "exif", "geotag", "leaflet", "smart-albums"],
387-
"version": "0.3.1",
387+
"version": "0.3.2",
388388
"status": "stable"
389389
},
390390
{

0 commit comments

Comments
 (0)