mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-09-21 13:31:42 +00:00
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
22 lines
738 B
TypeScript
22 lines
738 B
TypeScript
import type { FileEntry } from "./zip-reader.js";
|
|
|
|
export function crcFingerprint(entries: FileEntry[]): { crcs: string[]; complete: boolean } {
|
|
if (entries.length === 0) return { crcs: [], complete: false };
|
|
const crcs: string[] = [];
|
|
let complete = true;
|
|
for (const e of entries) {
|
|
if (e.crc32 == null) { complete = false; continue; }
|
|
crcs.push(e.crc32.toLowerCase());
|
|
}
|
|
crcs.sort();
|
|
return { crcs, complete };
|
|
}
|
|
|
|
export function fingerprintsMatch(a: FileEntry[], b: FileEntry[]): boolean {
|
|
const fa = crcFingerprint(a);
|
|
const fb = crcFingerprint(b);
|
|
if (!fa.complete || !fb.complete) return false;
|
|
if (fa.crcs.length !== fb.crcs.length) return false;
|
|
return fa.crcs.every((c, i) => c === fb.crcs[i]);
|
|
}
|