fix: honor underscore-unused convention and make durability fsyncs cross-platform

- eslint: respect the repo's existing _-prefix convention for unused vars
- phase-one-blockers: derive projectRoot via import.meta.dirname so Windows
  checkouts stop producing C:\C:\... paths
- backup/release-evidence/cutover-orchestrator: skip POSIX-only directory
  fsync on win32 and fsync read-only handles through a writable handle
This commit is contained in:
chick
2026-09-07 01:07:16 +08:00
parent f6319374cd
commit eed134a25c
5 changed files with 28 additions and 12 deletions
+8 -5
View File
@@ -289,11 +289,14 @@ async function durableState(plan: CutoverPlan, state: CutoverState): Promise<voi
await handle.close();
}
await rename(temporary, target);
const directory = await open(plan.stateDir, constants.O_RDONLY);
try {
await directory.sync();
} finally {
await directory.close();
if (process.platform !== 'win32') {
// directory fsync only exists on POSIX
const directory = await open(plan.stateDir, constants.O_RDONLY);
try {
await directory.sync();
} finally {
await directory.close();
}
}
}
@@ -159,7 +159,8 @@ async function digestFileHandle(handle: FileHandle): Promise<string> {
}
async function syncFile(path: string): Promise<void> {
const handle = await open(path, 'r');
// Windows FlushFileBuffers requires a writable handle; POSIX allows fsync on 'r'.
const handle = await open(path, process.platform === 'win32' ? 'r+' : 'r');
try {
await handle.sync();
} finally {
@@ -168,6 +169,7 @@ async function syncFile(path: string): Promise<void> {
}
async function syncDirectory(path: string): Promise<void> {
if (process.platform === 'win32') return; // directory fsync only exists on POSIX
const handle = await open(path, 'r');
try {
await handle.sync();
+8 -5
View File
@@ -254,11 +254,14 @@ export async function appendReleaseEvidence(
await handle.close();
}
await rename(temporary, absolute);
const directory = await open(parent, 'r');
try {
await directory.sync();
} finally {
await directory.close();
if (process.platform !== 'win32') {
// directory fsync only exists on POSIX
const directory = await open(parent, 'r');
try {
await directory.sync();
} finally {
await directory.close();
}
}
return Object.freeze(record);
} finally {