Skip to content

Multiple open Handles for the same file don't share metadata #287

@james-pre

Description

@james-pre

Multiple open Handles for the same file don't share metadata, meaning the inode can get out of sync.

Repro:

import * as fs from '@zenfs/core/promises'; // more readable

await fs.writeFile('example.txt', 'Hello World');

const a = fs.open('example.txt', 'r+');
const b = fs.open('example.txt', 'r+');

await a.truncate(5); // Contents are now "Hello"
const { size } = await b.stat();
assert.equal(size, 5); // fails because `b` doesn't have the updated metadata from `a`

The fix for this is to have Handles share their inode via a semi-global cache, which can be keyed using the FS' uuid and the file's ino.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions