mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
fix v1.41.2: uploaded files survive marker rebinding
- new WS houseplan/files/migrate moves /files/<oldId>/ to the new id (admin-only, sanitized ids, merge-safe, removes the empty old dir) - _saveMarker calls it and rewrites pdf urls (migratePdfUrls pure helper, +1 unit test, 112) when rebinding changes the id - field incident: the sauna heater manuals pointed at an orphaned old-id folder that got cleaned up; data restored by hand on the home instance (official Harvia PDFs re-downloaded) - TESTING/CHANGELOG same-commit
This commit is contained in:
@@ -965,6 +965,21 @@ export function outlineWithout(poly: number[][], cuts: number[][], eps = 1e-6):
|
||||
return cutSegments(edges, cuts, eps);
|
||||
}
|
||||
|
||||
// ---------------- marker files ----------------
|
||||
|
||||
/**
|
||||
* Rewrite attached-file urls when a marker's id changes (rebinding): the
|
||||
* server moves /files/<oldId>/ to /files/<newId>/, the urls must follow.
|
||||
*/
|
||||
export function migratePdfUrls<T extends { url: string }>(
|
||||
pdfs: T[], oldId: string, newId: string,
|
||||
): T[] {
|
||||
if (!oldId || !newId || oldId === newId) return pdfs;
|
||||
const from = '/files/' + oldId + '/';
|
||||
const to = '/files/' + newId + '/';
|
||||
return pdfs.map((p) => (p.url.includes(from) ? { ...p, url: p.url.split(from).join(to) } : p));
|
||||
}
|
||||
|
||||
// ---------------- kiosk gestures ----------------
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user