dat-node icon indicating copy to clipboard operation
dat-node copied to clipboard

DAT version discrepancies

Open martinheidegger opened this issue 5 years ago • 1 comments

(note: I am not sure if this is an issue of hyperdrive or dat-node, following @karissa 's suggestion to post it here - thanks @karissa )

I am reporting a bug or unexpected behavior:

The version of a newly created DAT when .ready is called persists at 0, even if a dedicated version is specified.

Bug Report

  • Operating system: Mac OS 10.13.6
  • Node Version: 10.12.0
  • dat-node Version: 3.5.15

Expected behavior

I am expecting the following code to properly list the version & files of that version.

const createDat = require('dat-node')

createDat(`${__dirname}/download`, {
  key: 'dat://56ff8bae4339defdb4bbe4e18d3fb5c17806429d59ce2e775b7832501c8781d1/',
  version: 11,
  temp: true
}, function (err, dat) {
  if (err) throw err
 
  dat.joinNetwork()
  
  dat.archive.ready(function () {
    console.log(`Version on ready: ${dat.archive.version}`)
  })

  dat.archive.readdir('/', function (err, list) {
    if (err) throw err
    console.log(`Version on list: ${dat.archive.version}`)
    console.log(list)
  })
})

to have following output

Version on ready: 11
Version on list: 11
[ 'LICENSE', 'README.md', 'images', 'dat.json', 'index.html' ]

Actual behavior

Version on ready: 0
Version on list: 11
[ 'LICENSE', 'README.md', 'images', 'dat.json', 'index.html' ]

martinheidegger avatar Nov 27 '18 02:11 martinheidegger

Ya, I've seen this before.

I think this happens when metadata isn't downloaded, returning a length of 0. But when I saw it before, it wasn't clear if that was a bug or something we should expect to happen.

joehand avatar Nov 27 '18 16:11 joehand