Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace fast-atomic-write with steno #285

Prev Previous commit
chore: update write rename error comments
SgtPooki committed Aug 6, 2024
commit 9b365b9164cc711c3b2c9eb8d962917de5759b78
5 changes: 2 additions & 3 deletions packages/blockstore-fs/src/index.ts
Original file line number Diff line number Diff line change
@@ -35,9 +35,8 @@ async function writeFile (file: string, contents: Uint8Array): Promise<void> {
await writer.write(contents)
} catch (err: any) {
if (err.syscall === 'rename' && ['ENOENT', 'EPERM'].includes(err.code)) {
// fast-write-atomic writes a file to a temp location before renaming it.
// On Windows, if the final file already exists this error is thrown.
// No such error is thrown on Linux/Mac
// steno writes a file to a temp location before renaming it.
// If the final file already exists this error is thrown.
// Make sure we can read & write to this file
await fs.access(file, fs.constants.F_OK | fs.constants.W_OK)

5 changes: 2 additions & 3 deletions packages/datastore-fs/src/index.ts
Original file line number Diff line number Diff line change
@@ -35,9 +35,8 @@ async function writeFile (path: string, contents: Uint8Array): Promise<void> {
await writer.write(contents)
} catch (err: any) {
if (err.syscall === 'rename' && ['ENOENT', 'EPERM'].includes(err.code)) {
// fast-write-atomic writes a file to a temp location before renaming it.
// On Windows, if the final file already exists this error is thrown.
// No such error is thrown on Linux/Mac
// steno writes a file to a temp location before renaming it.
// If the final file already exists this error is thrown.
// Make sure we can read & write to this file
await fs.access(path, fs.constants.F_OK | fs.constants.W_OK)