pub(crate) const ASSET_REF_CLAUSE: &str = "(EXISTS (SELECT 1 FROM asset_refs r WHERE r.asset_id = a.id) \
OR EXISTS (SELECT 1 FROM comments c \
WHERE c.deleted_at IS NULL AND c.content_html LIKE '%' || a.path || '%') \
OR EXISTS (SELECT 1 FROM users u WHERE u.avatar_url = '/uploads/' || a.path) \
OR EXISTS (SELECT 1 FROM friend_links f WHERE f.avatar_url = '/uploads/' || a.path))";Expand description
素材引用判定 SQL 片段(表别名固定为 a,即 assets)。
引用来源包括文章关联(asset_refs)、存活评论 HTML、用户头像和友链头像。
文章关联由索引重建维护;后三者保存的是直接 URL,因此在查询时按素材路径判断。