mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
Owner's decision after the incident: a detached plan is never deleted, at any age. v1.46.4 gave it a month; this makes it permanent and, more importantly, writes the reasoning where the next change will trip over it — docs/SCOPE.md now carries the standing rule. The component may delete a file only when a user action says so. 'Nothing points at this any more' is not such an action, because the two errors are not symmetrical: wasted disk is visible, cheap and reversible; a deleted file is none of those. Went through every other automatic deletion with the same question. One more was wrong: houseplan/files/cleanup rmtree'd whatever folder the card named. A partial migration leaves urls pointing into it — files/migrate deliberately does not rewrite the ones it could not confirm — so those were live links to files being deleted; and a wrong or stale id from any client destroyed a live device's manuals. The server now reads the stored config under its lock and removes only what nothing references, keeping the rest and saying so. Also: a plan of a DELETED space now waits thirty days rather than an hour. Deleting a space is deliberate; an hour is a short window to notice a misclick. The rest came out clean: layout/delete and marker/room/space removal are all confirm-guarded user actions, upload temporaries are never user-visible, and dropping legacy 'segments' is a documented migration.
44 lines
1.8 KiB
Python
Executable File
44 lines
1.8 KiB
Python
Executable File
"""Constants of the House Plan integration."""
|
|
|
|
DOMAIN = "houseplan"
|
|
STORAGE_KEY = f"{DOMAIN}.layout"
|
|
STORAGE_CONFIG_KEY = f"{DOMAIN}.config"
|
|
STORAGE_VERSION = 1
|
|
STORAGE_MINOR_VERSION = 1
|
|
FRONTEND_URL = "/houseplan_files/houseplan-card.js"
|
|
PLANS_URL = "/houseplan_files/plans"
|
|
PLANS_DIR = "houseplan/plans" # relative to the HA configuration directory
|
|
FILES_URL = "/houseplan_files/files"
|
|
# authenticated read path (audit B1): /api/houseplan/content/<plans|files>/<sub>/<name>
|
|
CONTENT_URL = "/api/houseplan/content"
|
|
|
|
# How many paths one houseplan/content/sign call may carry. The card batches to
|
|
# the same number; a client that sends more used to get a partial answer with no
|
|
# way to tell which paths were dropped (review R2-2).
|
|
MAX_SIGN_PATHS = 200
|
|
|
|
# An uploaded plan that no accepted configuration references is collected only
|
|
# once it is this old. Age is a race guard, not a policy: a plan uploaded
|
|
# seconds ago may belong to another client's transaction that has not written
|
|
# its configuration yet (review R3-1).
|
|
PLAN_ORPHAN_TTL_S = 3600
|
|
|
|
# The scheduled sweep is a different judgement from a commit's. A commit knows
|
|
# it replaced a file; the timer only knows nobody points at one right now — and
|
|
# "nobody points at it" is a normal, reversible state. Detaching a plan (switch
|
|
# a space to "draw") leaves the image on disk on purpose, and re-attaching it
|
|
# later is a thing people do. On 2026-07-28 the hourly rule applied to that case
|
|
# and removed two plans the owner had detached weeks earlier; they were not
|
|
# recoverable. So the timer waits a month, and never touches a plan or an
|
|
# attachment that still belongs to something in the configuration.
|
|
SCHEDULED_GRACE_S = 30 * 24 * 3600
|
|
FILES_DIR = "houseplan/files"
|
|
CONF_ADMIN_ONLY = "admin_only"
|
|
VERSION = "1.46.5"
|
|
|
|
DEFAULT_CONFIG: dict = {
|
|
"spaces": [],
|
|
"markers": [],
|
|
"settings": {},
|
|
}
|