Open way modify

This commit is contained in:
Eli-Class
2026-02-03 06:39:46 +00:00
parent 9eb4b17b34
commit 00635bdb67
7 changed files with 61 additions and 21 deletions

View File

@@ -151,6 +151,9 @@ export class IndexWriter {
this.dataFileSize = newDataEnd;
}
// Sync immediately after write
this.writeHeader();
return true;
}
@@ -158,7 +161,7 @@ export class IndexWriter {
return this.latestSequence;
}
syncHeader(): void {
writeHeader(): void {
if (!this.headerBuf || this.fd === null) return;
// Update header counts
@@ -177,7 +180,7 @@ export class IndexWriter {
if (this.fd === null) return;
// Sync header first
this.syncHeader();
this.writeHeader();
// Sync all file changes to disk
fs.fsyncSync(this.fd);
@@ -198,6 +201,16 @@ export class IndexWriter {
this.entryBuf = null;
}
writeFlags(flags: number): void {
if (!this.headerBuf || this.fd === null) {
throw new Error('Index file not opened');
}
IndexProtocol.writeFlags(this.headerBuf, flags);
fs.writeSync(this.fd, this.headerBuf, 41, 4, 41);
fs.fsyncSync(this.fd);
}
getStats() {
return {
path: this.path,