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:
@@ -10,6 +10,7 @@ import {
|
||||
outlineWithout,
|
||||
alignGuides, segmentAngle, is45,
|
||||
swipeTarget, clampScale,
|
||||
migratePdfUrls,
|
||||
segmentCm, formatLength, roomEdges, roomPoly, pointOnBoundary, pointStrictlyInside, roomsOverlap,
|
||||
mergeRooms, splitRoom, polygonArea, closestPointOnBoundary, isActiveState, snapToWall, openingAmount, fillColorsOf, lerpColor, roomFillStyle, stateIcon, lightColorOf, isAlarmState, parseRoomRef, diffNewDevices,
|
||||
} from '../test-build/logic.js';
|
||||
@@ -787,3 +788,15 @@ test('clampScale', () => {
|
||||
assert.equal(clampScale('x'), 1);
|
||||
assert.equal(clampScale(undefined, 1.5), 1.5);
|
||||
});
|
||||
|
||||
test('migratePdfUrls: rebinding rewrites file urls', () => {
|
||||
const pdfs = [
|
||||
{ name: 'a.pdf', url: '/houseplan_files/files/v_old1/a.pdf?v=1' },
|
||||
{ name: 'b.pdf', url: '/houseplan_files/files/other/b.pdf?v=2' },
|
||||
];
|
||||
const out = migratePdfUrls(pdfs, 'v_old1', 'dev99');
|
||||
assert.equal(out[0].url, '/houseplan_files/files/dev99/a.pdf?v=1');
|
||||
assert.equal(out[1].url, pdfs[1].url); // чужие пути не трогаем
|
||||
// без смены id — как есть
|
||||
assert.equal(migratePdfUrls(pdfs, 'x', 'x'), pdfs);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user