holepunchto / hyperdrive

Hyperdrive is a secure, real time distributed file system
Apache License 2.0
1.86k stars 135 forks source link

Unable to Read after Write #223

Closed eu1444 closed 6 years ago

eu1444 commented 6 years ago

I am reporting:

Bug Report

Please give us details about your installation to assist you. Run dat -v to see the version of Dat you are using.

Expected behavior

I have a gist that attempts to write two files, one via archive.writeFile() and one via archive.createWriteStream(). After writing those files I attempt to read them using archive.readFile(). I expect the files to exist and be able to be read.

My code can be found here: https://gist.github.com/mistersdevelopment/1abb082f948ff04a3412e686317270fe

Actual behavior

I receive "ENOENT: no such file or directory" errors for both reads.

Debug Logs

DEBUG=dat* node test.js   dat-node archive ready. version: 0 +0ms
  dat-node Replication error: Remote sent invalid feed message +0ms
  dat-node Stream close +1ms
Created Dat "58120d639dfe7cc7660a8e0ad56be7b38eaa295069db65a7e313132db50a0a81" with storage "test-dat"
Finished pipe.
Error:  { Error: ENOENT: no such file or directory, open 'test-dat/test.js.2'
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'test-dat/test.js.2' }
Finished writeFile.
Error:  { Error: ENOENT: no such file or directory, open 'test-dat/testWrite.txt'
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'test-dat/testWrite.txt' }
eu1444 commented 6 years ago

This issue is caused by dat-node defaulting the indexing option to true. Setting indexing to false fixes the issue.