release: v0.20.0

This commit is contained in:
Ralksta
2026-10-02 18:14:23 +02:00
committed by GitHub
parent 81ce886b01
commit 5f831f719a
209 changed files with 13807 additions and 803 deletions

View File

@@ -33,6 +33,9 @@ const STRIP_VERSION = 's1';
*/
const MAX_STRIP_BYTES = 64 * 1024 * 1024;
/** The shape of lib/urls.ts editMarker(): a base-36 timestamp. */
const EDIT_MARKER = /^[0-9a-z]{1,16}$/;
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
// ── Rate limiting ──────────────────────────────────
const ip = getClientIp(request);
@@ -86,6 +89,18 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
request.nextUrl.searchParams.get('w'),
);
// Photos edited in Immich (#831) are always served as edited: the server
// asks for `edited=true` on every request, whatever the URL says, so a URL
// stripped of its marker cannot bring back what a crop removed. For a photo
// that is not edited Immich returns the same bytes (measured on 3.2), and
// the parameter exists in every supported Immich (since 2.5; Folio needs
// 3.0). The marker `e` that lib/urls.ts writes for edited photos is only a
// cache key: it gives the edited rendition a URL (and ETag) of its own, so
// an `immutable` copy of the unedited one is never reused. A value outside
// the marker's shape is ignored, so it cannot carry anything into the ETag.
const editParam = request.nextUrl.searchParams.get('e');
const edit = editParam && EDIT_MARKER.test(editParam) ? editParam : null;
// ── Browser Cache Optimization ─────────────────────
// Use the opaque token to generate a safe ETag without leaking Immich UUIDs.
// IMAGE_CACHE_VERSION participates so that a bump is not defeated by a client
@@ -93,7 +108,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
// `immutable`, so this only matters after expiry or a cache eviction, but a
// matching ETag across two different URLs would be wrong either way.
const cacheVersion = request.nextUrl.searchParams.get('v') ?? '';
const etag = `W/"${token}-${size}-${STRIP_VERSION}${cacheVersion ? `-${cacheVersion}` : ''}"`;
const etag = `W/"${token}-${size}-${STRIP_VERSION}${edit ? `-e${edit}` : ''}${cacheVersion ? `-${cacheVersion}` : ''}"`;
if (request.headers.get('if-none-match') === etag) {
return new NextResponse(null, {
status: 304,
@@ -107,7 +122,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
let result;
try {
result = await immich.streamAsset(assetId, size);
result = await immich.streamAsset(assetId, size, true);
} catch (error) {
// An outage must not look like a deleted photo. These URLs are served with
// `immutable` on success, and a bare 404 is heuristically cacheable — so
@@ -177,7 +192,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
console.warn(
`[Image API] Original von ${assetId} (${contentType}) nicht strippbar — liefere Preview.`,
);
const preview = await immich.streamAsset(assetId, 'preview');
const preview = await immich.streamAsset(assetId, 'preview', true);
if (!preview) {
return NextResponse.json(
{ error: 'Asset not found' },