Exclude derived scene thumbnails from orphan findings

This commit is contained in:
2026-04-21 13:03:08 +00:00
parent b9161f219e
commit 7d299b31fe
3 changed files with 37 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
"id": "kosmos-storage-audit", "id": "kosmos-storage-audit",
"title": "Kosmos Storage Audit", "title": "Kosmos Storage Audit",
"description": "Analyzes media references and risky storage locations across Foundry data and public roots.", "description": "Analyzes media references and risky storage locations across Foundry data and public roots.",
"version": "0.0.19", "version": "0.0.20",
"compatibility": { "compatibility": {
"minimum": "13", "minimum": "13",
"verified": "13" "verified": "13"

View File

@@ -211,6 +211,7 @@ function wildcardToRegExp(pattern) {
} }
function shouldReportOrphan(file, references) { function shouldReportOrphan(file, references) {
if (isDerivedSceneThumbnail(file)) return false;
if (file.riskClass === "stable-world") { if (file.riskClass === "stable-world") {
const worldId = file.ownerHint.ownerId; const worldId = file.ownerHint.ownerId;
return references.some(reference => reference.sourceScope?.ownerType === "world" && reference.sourceScope.ownerId === worldId); return references.some(reference => reference.sourceScope?.ownerType === "world" && reference.sourceScope.ownerId === worldId);
@@ -224,6 +225,11 @@ function shouldReportOrphan(file, references) {
return false; return false;
} }
function isDerivedSceneThumbnail(file) {
const path = String(file.path ?? "");
return /^worlds\/[^/]+\/assets\/scenes\/[^/]+-thumb\.(?:png|webp)$/u.test(path);
}
export function createFileRecord(locator, size = null) { export function createFileRecord(locator, size = null) {
return { return {
...locator, ...locator,

View File

@@ -0,0 +1,30 @@
import assert from "node:assert/strict";
import { buildFindings, createFileRecord } from "../scripts/core/finding-engine.js";
import { createFileLocator } from "../scripts/core/path-utils.js";
const files = [
createFileRecord(createFileLocator("data", "worlds/demo-world/assets/scenes/exampleScene-thumb.webp"), 1234)
];
const references = [
{
sourceType: "world-document",
sourceScope: { ownerType: "world", ownerId: "demo-world", systemId: "demo-system", subtype: "actors" },
sourceLabel: "Actor demo",
rawValue: "worlds/demo-world/assets/actors/portrait.webp",
normalized: {
...createFileLocator("data", "worlds/demo-world/assets/actors/portrait.webp"),
targetKind: "local-file"
}
}
];
const findings = buildFindings({ files, references });
assert.equal(
findings.some(finding => finding.kind === "orphan-file" && finding.target.locator === "data:worlds/demo-world/assets/scenes/exampleScene-thumb.webp"),
false,
"derived scene thumbnails should not be reported as orphaned"
);
console.log("scene-thumbnail-orphan-test: ok");