diff --git a/packages/db/src/FileFlatDb/Compact.ts b/packages/db/src/FileFlatDb/Compact.ts index 6a6097cef..79ad7cd7d 100644 --- a/packages/db/src/FileFlatDb/Compact.ts +++ b/packages/db/src/FileFlatDb/Compact.ts @@ -53,7 +53,7 @@ export default class Compact { fs.writeFileSync(file, Buffer.alloc(defaults.BRANCH_SIZE)); } - return fs.openSync(file, 'a+'); + return fs.openSync(file, 'r+'); } private _compact (fn: ProgressCb, newFd: number, oldFd: number): number { diff --git a/packages/db/src/FileFlatDb/index.ts b/packages/db/src/FileFlatDb/index.ts index 3b1b01f76..eb0df4fbf 100644 --- a/packages/db/src/FileFlatDb/index.ts +++ b/packages/db/src/FileFlatDb/index.ts @@ -485,6 +485,6 @@ export default class FileFlatDb implements BaseDb { fs.writeFileSync(file, Buffer.alloc(defaults.BRANCH_SIZE)); } - return fs.openSync(file, 'a+'); + return fs.openSync(file, 'r+'); } }