Open joehand opened 7 years ago
@benrogmans you can address this for now by using the indexing option:
var Dat = require('dat')
var filePath = 'hello.txt'
var fileContent = 'echo 123'
Dat('./test', {indexing: false}, function (err, dat) {
if (err) throw err
dat.archive.writeFile(filePath, fileContent, function (err) {
if (err) throw err
console.log('done')
})
})
Sorry, this is a bit hacky. Normally in dat-node we import "in-place" (e.g. files are just being scanned, not created). If files aren't imported in place, we set the indexing false. But those assumptions all fail in this case.
I may make false the default since this is definitely unexpected and not user friendly. But we had some unresolved TODOs around the indexing that I need to refresh myself on to see if we can solve more directly.
I thought this would also fix #164 but that seems to be a separate issue.
found out more about this issue here: https://github.com/datproject/dat-storage/issues/7.
With { indexing: true }
, not just the files aren't created on disk, a following dat.archive.readFile()
also can't read them.
This is a temporary fix for multidat: https://github.com/datproject/multidat/commit/11b702bc7a7b312b9c42387ff4e9b594885bce3d
Writing a file from archive in
dat-node
results in empty file.However, this works with plain hyperdrive and dat-storage: