Exclude derived scene thumbnails from orphan findings
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"id": "kosmos-storage-audit",
|
||||
"title": "Kosmos Storage Audit",
|
||||
"description": "Analyzes media references and risky storage locations across Foundry data and public roots.",
|
||||
"version": "0.0.19",
|
||||
"version": "0.0.20",
|
||||
"compatibility": {
|
||||
"minimum": "13",
|
||||
"verified": "13"
|
||||
|
||||
@@ -211,6 +211,7 @@ function wildcardToRegExp(pattern) {
|
||||
}
|
||||
|
||||
function shouldReportOrphan(file, references) {
|
||||
if (isDerivedSceneThumbnail(file)) return false;
|
||||
if (file.riskClass === "stable-world") {
|
||||
const worldId = file.ownerHint.ownerId;
|
||||
return references.some(reference => reference.sourceScope?.ownerType === "world" && reference.sourceScope.ownerId === worldId);
|
||||
@@ -224,6 +225,11 @@ function shouldReportOrphan(file, references) {
|
||||
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) {
|
||||
return {
|
||||
...locator,
|
||||
|
||||
30
tests/scene-thumbnail-orphan-test.mjs
Normal file
30
tests/scene-thumbnail-orphan-test.mjs
Normal 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");
|
||||
Reference in New Issue
Block a user