New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperdrive/hyperdb file storage issues #215

Open
joehand opened this Issue Apr 27, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@joehand
Collaborator

joehand commented Apr 27, 2018

Bug:

All files are getting appended to the first file imported.

Cause:

Seems like the file.end is not getting set (not sure how that should get set).

In the _find function of lib/storage the first file is always returned because file.start = 0 and file.end = Infinity, so the offset is always between those two.

ContentStorage.prototype._find = function (offset, cb) {
  for (var i = 0; i < this.files.length; i++) {
    var file = this.files[i]
    // ALWAYS RETURNS FIRST FILE
    if (file.start <= offset && offset < file.end) {
      return cb(null, file)
    }
  }

  this._findInFeed(offset, cb)
}

https://github.com/mafintosh/hyperdrive/blob/hyperdb-backend/lib/storage.js#L53-L62

Reproduce

You can use reproduce with this repo https://github.com/datproject/dat-node/tree/hyperdb by running node examples/share.js. Everything will get appended to CHANGELOG.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment