You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importfsDriverfrom'unstorage/drivers/fs-lite'constfs=fsDriver({base: '/tmp'})awaitfs.setItem('foo',"test")awaitfs.setItem('foo/bar',"test")// ENOTDIR - foo is not a directory (because it is a file)
Describe the bug
When using the fs-lite or fs driver, file and folders are conflicting. This is likely the case with some other filesystem based drivers (like azure)
Additional context
An extension should be appended transparently to cache files to avoid conflicts with folders, as otherwise filesystem drivers have a different behavior/limitation than a memory driver.
Another possibility would be to use a hash of the cache key for storage path instead, as this would solve issues with forbidden fs characters as well or path traversal security issues.
Logs
node:internal/fs/promises:639
return new FileHandle(await PromisePrototypeThen(
^
Error: ENOTDIR: not a directory, open 'foo/bar'
at async open (node:internal/fs/promises:639:25)
at async Object.writeFile (node:internal/fs/promises:1219:14)
at async file://test.js:4:1 {
errno: -20,
code: 'ENOTDIR',
syscall: 'open',
path: '/foo/bar'
}
Node.js v22.22.2
this could easily be solved by prefixing files with a literal :, since that can't be used as a character in key names. It should be entirely unproblematic to just do this, since the real file path isn't part of any stable API design. Existing setups could be migrated by renaming files at startup
Activity
[-]Fs lite driver design issue[/-][+]Generalized design issue[/+][-]Generalized design issue[/-][+]Generalized fs driver design issue[/+]fix(fs): throw ENOTDIR when setItem key prefix is an existing file (u…
fix(fs): throw ENOTDIR when setItem key prefix is an existing file (u…
LMR-eitea commentedon Oct 29, 2026
this could easily be solved by prefixing files with a literal
:, since that can't be used as a character in key names. It should be entirely unproblematic to just do this, since the real file path isn't part of any stable API design. Existing setups could be migrated by renaming files at startuplet me know if I'm missing something