refactor(resources): share artifact cleanup error composition (#14457)

* refactor(resources): share artifact cleanup error composition

* refactor(resources): require a classified reader failure for cleanup
This commit is contained in:
Vincent Koc authored and GitHub committed 2026-11-25 08:30:04 -05:00
1 parent f9ee091df2
commit 79f0f2f3fd
5 files changed
+36 -53

No files matched your search

+6 -13
View File
@@ -30,10 +30,9 @@ import {
artifactFilePrimaryFacts,
type ArtifactFilePrimaryFacts,
artifactFileCompletion,
bindArtifactFileCleanup,
withArtifactCleanupFailure,
assertArtifactReadActive,
} from "../resources/index.js";
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
import type { ExecutionOptions } from "../ports/AnalysisProvider.js";
import type { Il2cppMetadataPort } from "../ports/il2cpp/Il2cppMetadataPort.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
@@ -60,7 +59,6 @@ import {
import { ELF_VIRTUAL_POINTER_INDEX_LIMIT } from "../domain/native/elfPointerRelocations.js";
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { err, ok, type Result } from "../domain/result.js";
import {
readIl2cppMetadataForLinkingSteps,
@@ -228,23 +226,18 @@ const failureFor = (
maximum,
metadataPath,
);
if (!(cause instanceof ArtifactReaderFailure)) return primary;
if (
cause instanceof ArtifactReaderFailure &&
cause.partialObservation !== undefined &&
primary.partialObservation === undefined
)
primary.retainPartialObservation(cause.partialObservation);
if (!(cause instanceof ArtifactReaderFailure) || cause.cleanup === undefined)
return primary;
const cleanup = new ProviderCleanupError(
return withArtifactCleanupFailure(
cause,
primary,
IL2CPP_METADATA_PROVIDER_IDENTITY.id,
cause.cleanup.resources,
{ reason: cause.cleanup.reason },
{ operation: OPERATION, cause },
OPERATION,
);
const error = analysisErrorWithCleanupFailure(primary, cleanup, OPERATION);
bindArtifactFileCleanup(cause, error);
return error;
};
/** Report fields for a linked binary, with addresses as exact hexadecimal strings. */