Js-ipfs: --only-hash option with directory hashes only one file

Created on 17 Dec 2019  路  4Comments  路  Source: ipfs/js-ipfs

jsipfs add <directory> -r --only-hash outputs hash only for the first file

  • Version: 0.40.0
  • Platform: x64/linux
  • Subsystem: v12.13.0

Type: Bug

Severity: Low?

Description:

When trying to add a directory with --only-hash option it only outputs hash of one file in that directory. Unlike go-ipfs, which works correctly

Steps to reproduce the error:

./ipfs$ ls temp_folder/
file1.txt  file2.txt

./ipfs$ ipfs add temp_folder/ -r --only-hash
added QmUbWZYLu5YBnzbxtkgv6BoXmvjMfHTFiU1L9G3DABiAHZ temp_folder/file1.txt
added QmZ1sZS9Xp5PdkdQ2mf9tJuBaVRxEX2eBsbzeQ9FvoqBKJ temp_folder/file2.txt
added QmVcSRW5fbqQNxc5RxMKsfMDcJ8xHTULvQViPfnX68hAG1 temp_folder
 32 B / 32 B [=========================================================]

./ipfs$ jsipfs add temp_folder/ -r --only-hash
added QmUbWZYLu5YBnzbxtkgv6BoXmvjMfHTFiU1L9G3DABiAHZ temp_folder/file1.txt
P3 dieasy kinbug statuin-progress

All 4 comments

I think the return here should be a continue:

https://github.com/ipfs/js-ipfs/blob/0565f479a2d6bdce471ae60a9388754dc2fe1611/src/core/components/files-regular/add-async-iterator.js#L84-L92

I actually spotted this and changed it in https://github.com/ipfs/js-ipfs/pull/2683/files#diff-3891f448a2eed338148ea3e5f82c4c18R62-R70

@achingbrain does that look right to you?

Yes, looks right. Should be a simple fix - @Velenir would you like to submit a PR for this?

If you could add a test similar to this one that tests directories (or just importing multiple things) it should prevent a regression in future.

This has been resolved in #2726 and a test added in ipfs/interface-js-ipfs-core#587

@Velenir you can now use the RC release 0.41.0-rc.0 which has this fix in it.

Was this page helpful?
0 / 5 - 0 ratings