Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

How do you tell when a dat download has finished?Β #218

@ryuheiyokokawa

Description

@ryuheiyokokawa

I am reporting:

  • a bug or unexpected behavior
  • general feedback
  • feature request
  • security issue

Bug Report

  • Operating system: macOS High Sierra / Fedora 27 (both)
  • Node Version: 8.9.3
  • dat-node Version: 3.5.12 (whatever is pulling from npm as latest at the moment)

Expected behavior/methods

We can't tell when the dat is finished downloading definitively and safely.
Maybe have something like dat.on('finished-download') or similar?

Actual behavior

No documentation on how we should detecting finished download?

const stats = dat.trackStats()
stats.on('update', () => {
    const newStats = stats.get()
    if(newStats.length.length == newStats.downloaded.length) {
        //Is it done?
    }
})

Also looked into this:

dat.archive.stat(newDatPath, { wait: true } ,() => {})

This seems closer looking at the hyperdrive archive to see if its finished. This didn't make the next issue go away though.
It looks like there is a delay between the time the blocks are downloaded and the time its written to disk. Is this the reason why you guys use ram and mirror the files over to have a way of knowing if the files have finished downloads? Saw that in the example here.

We weren't sure we'd want to use RAM for something that could be gigs in size. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions