Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Empty hash, zero type and zero size for ls files in directory #17

Closed
alanshaw opened this issue Oct 22, 2018 · 0 comments
Closed

Empty hash, zero type and zero size for ls files in directory #17

alanshaw opened this issue Oct 22, 2018 · 0 comments

Comments

@alanshaw
Copy link

Test script:

const IPFS = require('ipfs')
const Path = require('path')
const Os = require('os')

const ipfs = new IPFS({ repo: Path.join(Os.tmpdir(), `${Date.now()}`) })

ipfs.on('ready', async () => {
  const files = Array.from([1, 2, 3], i => ({
    path: `test-file-${Date.now()}-${i}`,
    content: Buffer.from(`data ${Date.now()} ${i}`)
  }))

  const res = await ipfs.files.add(files, { wrapWithDirectory: true })

  console.log('Added files:')
  console.log(res)

  const { hash } = res[res.length - 1]

  const ipfsPath = `/ipfs/${hash}`
  console.log(`Copying from ${ipfsPath}`)

  const mfsPath = `/test-dir-${Date.now()}`
  console.log(`Copying to ${mfsPath}`)

  await ipfs.files.cp(ipfsPath, mfsPath)

  console.log(`Directory listing of ${mfsPath}:`)
  console.log(await ipfs.files.ls(mfsPath))
})

Output:

$ node ls-bug.js 
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/ipfs/QmXk7xmWA4yShKUwXN7JZXatFX6ATRVYHzkL52tngTxhiW
Swarm listening on /ip4/127.0.0.1/tcp/4002/ipfs/QmXk7xmWA4yShKUwXN7JZXatFX6ATRVYHzkL52tngTxhiW
Swarm listening on /ip4/192.168.1.85/tcp/4002/ipfs/QmXk7xmWA4yShKUwXN7JZXatFX6ATRVYHzkL52tngTxhiW
Added files:
[ { path: 'test-file-1540199056673-3',
    hash: 'QmRDi9soVyiuwbV5t51v7KnmGeY1tNGSLqeXsnFVupf7fS',
    size: 28 },
  { path: 'test-file-1540199056673-2',
    hash: 'QmV7nqHzxvjwcCD8Qda9DpwJ5wwLEWpZCTf48gJswiUVbD',
    size: 28 },
  { path: 'test-file-1540199056673-1',
    hash: 'QmVd2S29ciJvwZutbNQKrnnBfrUxwztWMDPCoVUjoDZFud',
    size: 28 },
  { path: '',
    hash: 'QmQCdSt7BNokYuGL5prjhcv22eSSumqza3vN7YWWDFHXAX',
    size: 289 } ]
Copying from /ipfs/QmQCdSt7BNokYuGL5prjhcv22eSSumqza3vN7YWWDFHXAX
Copying to /test-dir-1540199056875
Directory listing of /test-dir-1540199056875:
[ { name: 'test-file-1540199056673-3', type: 0, hash: '', size: 0 },
  { name: 'test-file-1540199056673-2', type: 0, hash: '', size: 0 },
  { name: 'test-file-1540199056673-1', type: 0, hash: '', size: 0 } ]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant