Add safe Metadata document ID repair

This commit is contained in:
vorotamoroz
2026-08-12 18:56:17 +00:00
parent eda78dee36
commit c933674a0d
13 changed files with 715 additions and 9 deletions
@@ -0,0 +1,31 @@
import type { MetadataDocumentIdentityIssue } from "@vrtmrz/livesync-commonlib/compat/serviceFeatures/offlineScanner";
import { stripAllPrefixes } from "@vrtmrz/livesync-commonlib/compat/string_and_binary/path";
import type { FilePathWithPrefix } from "@vrtmrz/livesync-commonlib/compat/common/types";
export function metadataIdentityPathKey(path: string, handleFilenameCaseSensitive: boolean): string {
const vaultPath = stripAllPrefixes(path as FilePathWithPrefix);
return handleFilenameCaseSensitive ? vaultPath : vaultPath.toLowerCase();
}
/**
* Select unresolved identity evidence for read-only presentation and create
* the path keys which must be withheld from ordinary path-based repair.
*/
export function selectUnresolvedMetadataIdentityEntries(
entries: readonly MetadataDocumentIdentityIssue[],
handleFilenameCaseSensitive: boolean
): {
entries: MetadataDocumentIdentityIssue[];
unresolvedPathKeys: ReadonlySet<string>;
} {
return {
entries: [...entries],
unresolvedPathKeys: new Set(
entries
.filter(({ ordinaryPathAvailable }) => !ordinaryPathAvailable)
.map(({ inspection }) =>
metadataIdentityPathKey(inspection.diagnostic.declaredPath, handleFilenameCaseSensitive)
)
),
};
}