Startup crash on shallow Dahua layout: parents[4] resolves to wrong directory #140
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
During startup scan,
_scan_snapshots_for_cameracrashes with:Only cameras using the shallow Dahua layout trigger this; deep-layout cameras work fine.
Root cause
lifespan.pyline 100 usessource_path.parents[4]to find the date directory for pruning. This hard-codes the deep Dahua layout depth (6 levels:cam_root/YYYY-MM-DD/channel/jpg/HH/MM/SS.jpg). The shallow layout is one level shallower (5 levels:cam_root/YYYY-MM-DD/channel/jpg/HH.MM.SS.jpg), soparents[4]lands oncam_root— a serial number directory likeAF007D8PAG5B66F, not an ISO date.Fix
Use
snapshot.date(already parsed by the Dahua adapter) and construct the date directory ascam.root / snapshot.date.isoformat()instead of fragile parent traversal. This works identically for both layouts.Plan
source_path.parents[4]withcam.root / snapshot.date.isoformat()in_scan_snapshots_for_camera(src/cang/web/lifespan.pyline 100)snapshot.datefield is already parsed by the adapter — no new parsing neededdate.fromisoformat(date_dir.name)check becomessnapshot.date < todayBranch:
fix/issue-140-141-regressionsCommits:
:bug: Fix startup crash on shallow Dahua layout by using snapshot.date instead of path traversal:bug: Fix deploy-docs CI regex to accept 4-part micro-calver tagsPlan: use snapshot.date instead of parents[4] for date directory path