release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of [CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md) for the full list. Highlights: client proofing links (#683), custom content pages (#738), asset picker search (#740), concurrent-edit detection (#742), env-locked settings (#739), an accessibility baseline (#741), three security fixes with advisories (#737, #755, #759), and a pre-release quality pass (#780–#797). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ralf <rohlenbo79@gmail.com> Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com> Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com> Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
This commit is contained in:
@@ -4,6 +4,16 @@ import path from 'path';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { withAdmin } from '@/lib/admin/withAdmin';
|
||||
import { atomicWrite } from '@/lib/atomicWrite';
|
||||
import {
|
||||
VersionConflictError,
|
||||
assertVersion,
|
||||
baseVersionFrom,
|
||||
conflictResponse,
|
||||
etag,
|
||||
fileVersion,
|
||||
serializeContentWrite,
|
||||
versionOf,
|
||||
} from '@/lib/admin/contentVersion';
|
||||
import { getConfig } from '@/lib/config';
|
||||
import { env } from '@/lib/env';
|
||||
import { PRIVACY_FILENAME, processingFacts, readPrivacy, starterHeadings } from '@/lib/privacy';
|
||||
@@ -26,14 +36,19 @@ export const GET = withAdmin(async () => {
|
||||
config.subpages.some((sp) => !!sp.password) ||
|
||||
Object.values(config.albumPasswords).some(Boolean),
|
||||
});
|
||||
// Read before the text: a save landing between the two then makes the
|
||||
// version stale, which costs a spurious conflict, never a missed one.
|
||||
const version = await fileVersion(path.join(CONTENT_DIR, PRIVACY_FILENAME));
|
||||
return NextResponse.json(
|
||||
{
|
||||
body: readPrivacy(CONTENT_DIR),
|
||||
// Sent back in If-Match on save (#601).
|
||||
version,
|
||||
enabled: config.privacy.enabled,
|
||||
facts,
|
||||
starter: starterHeadings(config.lang, facts),
|
||||
},
|
||||
{ headers: { 'Cache-Control': 'no-store' } },
|
||||
{ headers: { 'Cache-Control': 'no-store', ETag: etag(version) } },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -45,34 +60,48 @@ export const PUT = withAdmin(async (request: Request) => {
|
||||
}
|
||||
|
||||
const filePath = path.join(CONTENT_DIR, PRIVACY_FILENAME);
|
||||
await fs.mkdir(CONTENT_DIR, { recursive: true });
|
||||
|
||||
// Same rule as the about route (#630): only a missing file means there is
|
||||
// nothing to back up. Any other failure aborts before the live file changes.
|
||||
let fileExists = true;
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;
|
||||
fileExists = false;
|
||||
}
|
||||
|
||||
if (fileExists) {
|
||||
const backupDir = path.join(CONTENT_DIR, '.backups');
|
||||
await fs.mkdir(backupDir, { recursive: true });
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
await fs.copyFile(filePath, path.join(backupDir, `${PRIVACY_FILENAME}.${timestamp}.bak`));
|
||||
const backups = (await fs.readdir(backupDir))
|
||||
.filter((e) => e.startsWith(PRIVACY_FILENAME) && e.endsWith('.bak'))
|
||||
.sort();
|
||||
while (backups.length > MAX_BACKUPS) {
|
||||
await fs.unlink(path.join(backupDir, backups.shift()!));
|
||||
}
|
||||
}
|
||||
|
||||
const body = data.body.trim();
|
||||
await atomicWrite(filePath, body ? `${body}\n` : '');
|
||||
const content = body ? `${body}\n` : '';
|
||||
const baseVersion = baseVersionFrom(request);
|
||||
try {
|
||||
await serializeContentWrite(async () => {
|
||||
await assertVersion(filePath, baseVersion);
|
||||
await fs.mkdir(CONTENT_DIR, { recursive: true });
|
||||
|
||||
// Same rule as the about route (#630): only a missing file means there is
|
||||
// nothing to back up. Any other failure aborts before the live file changes.
|
||||
let fileExists = true;
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;
|
||||
fileExists = false;
|
||||
}
|
||||
|
||||
if (fileExists) {
|
||||
const backupDir = path.join(CONTENT_DIR, '.backups');
|
||||
await fs.mkdir(backupDir, { recursive: true });
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
await fs.copyFile(filePath, path.join(backupDir, `${PRIVACY_FILENAME}.${timestamp}.bak`));
|
||||
const backups = (await fs.readdir(backupDir))
|
||||
.filter((e) => e.startsWith(PRIVACY_FILENAME) && e.endsWith('.bak'))
|
||||
.sort();
|
||||
while (backups.length > MAX_BACKUPS) {
|
||||
await fs.unlink(path.join(backupDir, backups.shift()!));
|
||||
}
|
||||
}
|
||||
|
||||
await atomicWrite(filePath, content);
|
||||
});
|
||||
} catch (err) {
|
||||
if (err instanceof VersionConflictError) return conflictResponse(err.currentVersion);
|
||||
throw err;
|
||||
}
|
||||
revalidatePath('/', 'layout');
|
||||
|
||||
return NextResponse.json({ success: true, message: 'Privacy policy saved.' });
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Privacy policy saved.',
|
||||
version: versionOf(content),
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user