@davideasden/pi-undo 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/durable-pack.ts
CHANGED
|
@@ -446,21 +446,17 @@ export async function finalizeDurablePack(
|
|
|
446
446
|
throw error;
|
|
447
447
|
});
|
|
448
448
|
if (targetArtifactExists) {
|
|
449
|
+
// identity 已证明 absolute 与 target artifact 指向同一 inode,pre/post fsync 各确认一次绑定即可。
|
|
449
450
|
await assertSameFileIdentity(absolute, targetArtifact, path);
|
|
450
|
-
if (await fingerprintFile(absolute, path) !== leaf.fingerprint) {
|
|
451
|
-
throw new Error(`durable finalization 文件 fingerprint 冲突:${path}`);
|
|
452
|
-
}
|
|
453
451
|
await fsyncFile(targetArtifact);
|
|
454
452
|
await assertSameFileIdentity(absolute, targetArtifact, path);
|
|
455
453
|
} else {
|
|
456
454
|
if (mutationStates?.get(path) !== "CLEANED") {
|
|
457
455
|
throw new Error(`durable finalization target ownership 缺失:${path}`);
|
|
458
456
|
}
|
|
459
|
-
if (await fingerprintFile(absolute, path) !== leaf.fingerprint) {
|
|
460
|
-
throw new Error(`durable finalization 文件 fingerprint 冲突:${path}`);
|
|
461
|
-
}
|
|
462
457
|
await fsyncFile(absolute);
|
|
463
458
|
}
|
|
459
|
+
// 落盘后必须从磁盘读回比对:pack bytes 只证明 pack 自身一致,不能证明工作区文件已正确写入。
|
|
464
460
|
if (await fingerprintFile(absolute, path) !== leaf.fingerprint) {
|
|
465
461
|
throw new Error(`durable finalization 后文件 fingerprint 冲突:${path}`);
|
|
466
462
|
}
|