Skip to content

Generalized fs driver design issue #775

Open

Description

@Tofandel

Environment

Reproduction

import fsDriver from 'unstorage/drivers/fs-lite'
const fs = fsDriver({base: '/tmp'})
await fs.setItem('foo', "test")
await fs.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 issue is in turn causing nuxt/nuxt#34961

Activity

  1. added
    bug
    on May 11, 2026
  2. changed the title [-]Fs lite driver design issue[/-] [+]Generalized design issue[/+] on May 11, 2026
  3. changed the title [-]Generalized design issue[/-] [+]Generalized fs driver design issue[/+] on May 11, 2026
  4. LMR-eitea commented on Oct 29, 2026

    @LMR-eitea

    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

    let me know if I'm missing something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions