holepunchto / hyperdrive

Hyperdrive is a secure, real time distributed file system
Apache License 2.0
1.85k stars 136 forks source link

shallowReadStream: Use only entry prefix for directory keys #356

Closed josephmturner closed 11 months ago

josephmturner commented 11 months ago

This change makes drive.list(folder, { recursive: false }) return only the entry prefix key for directories.

Given that the root directory contains

/foo
/bar/baz
/bar/quux

Previously, drive.list('/', { recursive: false }) returned

{
  seq: 42,
  key: '/foo',
  value: { ... }
}
{
  seq: 43,
  key: '/bar/baz',  // Expected key: '/bar'
  value: { ... }
}

Now, drive.list('/', { recursive: false }) returns

{
  seq: 42,
  key: '/foo',
  value: { ... }
}
{
  key: '/bar',
}

Note that seq and value properties have been thrown away since they don't belong to the entry prefix.

mafintosh commented 11 months ago

Thats what readdir is for. List is for returning actual nodes

josephmturner commented 11 months ago

Thanks. That makes sense.