holepunchto / hyperdrive

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

Inconsistent size for directories readdir / stat #272

Closed martinheidegger closed 1 year ago

martinheidegger commented 4 years ago

I noticed that when running a hyperdrive 10.8.20 that the stat returned by a readdir returns a different size:

const hyperdrive = require('hyperdrive')
const ram = require('random-access-memory')
const drive = hyperdrive(ram)
const assert = require('assert')

drive.writeFile('test/test.txt', 'hello', () => {
  drive.readdir('/', { includeStats: true }, (_, readdir) => {
    const name = readdir[0].name
    assert.equal(name, 'test')
    drive.stat(name, (_, stat) => {
      assert.equal(readdir[0].stat.size, stat.size) // should pass but fails with 0 == 5
    })
  })
})