hyperdrive icon indicating copy to clipboard operation
hyperdrive copied to clipboard

indexing should be option on write stream, not hyperdrive

Open joehand opened this issue 7 years ago • 3 comments

opts.indexing doesn't make sense on the wholee hyperdrive. We may want to import in place and from another directory for the same archive. It should be on the write stream instead.

joehand avatar May 05 '17 17:05 joehand

Got another use case for this in dat-json. I'd like to write dat.json file directly to archive but also update anything on the fs (or wherever storage is).

The createWritingStream option would be a bit tough here since it outsources writing to toiletdb. So perhaps doing the archive.defaults({indexing: false}) approach would be nicer. We can generally assume any module writing to the archive will have the archive available.

Currently I have to do this:

fileDb.write(key, val, function (err) { // writes to a dat.json on filesystem
  if (err) return cb(err)
  db.write(key, val, cb) // writes to archive
})

It'd be nice to do this:

var indexing = archive.defaults.indexing
archive.defaults({indexing: false})

// write to archive + storage
db.write(key, val, function (err) {
  archive.defaults({indexing: indexing}) // reset val
  cb(err)
}) 

joehand avatar May 17 '17 18:05 joehand

Not sure if it's related, but if I create a Dat with {temp: true}, archive.readdir() always returns an empty array. If it's unrelated, I can open another issue.

millette avatar Jun 14 '17 17:06 millette

Not sure if it's related, but if I create a Dat with {temp: true}, archive.readdir() always returns an empty array. If it's unrelated, I can open another issue

@millette, that sounds like a issue with dat-node (I assume thats what you're using with temp). There were a few temp edge cases I hadn't worked out, so please open an issue if you see something wrong with there.

joehand avatar Jun 14 '17 19:06 joehand