mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 16:38: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:
+12
-2
@@ -14,7 +14,7 @@ import {
|
||||
import {
|
||||
lqiColor, snapToGrid, samePoint, pointInPolygon, markerIdForBinding,
|
||||
segmentCm, formatLength, roomEdges, roomPoly, pointStrictlyInside, roomsOverlap,
|
||||
pointOnBoundary, mergeRooms, splitRoomPath, polygonArea, closestPointOnBoundary, pointStrictlyInside as ptInside, islandsOf, sharedBoundary, openZoneOf, distToSegment, outlineWithout, cutSegments, alignGuides, segmentAngle, is45, type AlignGuide, swipeTarget, clampScale,
|
||||
pointOnBoundary, mergeRooms, splitRoomPath, polygonArea, closestPointOnBoundary, pointStrictlyInside as ptInside, islandsOf, sharedBoundary, openZoneOf, distToSegment, outlineWithout, cutSegments, alignGuides, segmentAngle, is45, type AlignGuide, swipeTarget, clampScale, migratePdfUrls,
|
||||
snapToWall, openingAmount,
|
||||
averageLqi, fitView, declump, safeUrl, resolveTapAction, floorsOf, type FloorInfo,
|
||||
stateIcon, lightColorOf, isAlarmState, parseRoomRef, diffNewDevices, glowColorOf, doorSector, hasRoomBehind, controlsAction, isControllable,
|
||||
@@ -32,7 +32,7 @@ import './space-card';
|
||||
import { cardStyles } from './styles';
|
||||
import { langOf, t, type I18nKey } from './i18n';
|
||||
|
||||
const CARD_VERSION = '1.41.1';
|
||||
const CARD_VERSION = '1.41.2';
|
||||
const LS_KEY = 'houseplan_card_layout_v1';
|
||||
const LS_CFG = 'houseplan_card_cfg_v1'; // cache of the server config+layout for instant rendering
|
||||
const LS_ZOOM = 'houseplan_card_zoom_v1';
|
||||
@@ -2459,6 +2459,7 @@ class HouseplanCard extends LitElement {
|
||||
angle: dlg.angle ? dlg.angle : null,
|
||||
tap_action: dlg.tapAction || null,
|
||||
controls: dlg.controls.length ? dlg.controls : null,
|
||||
// pdfs may be rewritten below when rebinding changes the marker id
|
||||
glow_radius_cm: (() => {
|
||||
const v = parseFloat(dlg.glowRadius);
|
||||
if (!Number.isFinite(v) || v <= 0) return null;
|
||||
@@ -2480,6 +2481,15 @@ class HouseplanCard extends LitElement {
|
||||
const prevRoomId = prevDev?.marker?.room_id ?? null;
|
||||
const roomChanged = !!dlg.room && prevDev != null
|
||||
&& (prevDev.space !== space || prevDev.area !== area || prevRoomId !== roomId);
|
||||
// rebinding changed the id → move the uploaded files along (server-side)
|
||||
// and rewrite the attached urls; otherwise the old-id folder goes orphan
|
||||
// (that is how the sauna manuals were lost — incident 2026-07-26)
|
||||
if (oldId && oldId !== id && marker.pdfs?.length) {
|
||||
await this.hass
|
||||
.callWS({ type: 'houseplan/files/migrate', from_id: oldId, to_id: id })
|
||||
.catch(() => undefined);
|
||||
marker.pdfs = migratePdfUrls(marker.pdfs, oldId, id);
|
||||
}
|
||||
// remove the previous marker (by the old id and by the new id)
|
||||
cfg.markers = cfg.markers.filter((m) => m.id !== id && m.id !== oldId);
|
||||
cfg.markers.push(marker);
|
||||
|
||||
Reference in New Issue
Block a user