Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

jsipfs cat on a directory not working correctly #1142

Closed
alanshaw opened this issue Dec 11, 2017 · 7 comments · Fixed by #1143 or #1148
Closed

jsipfs cat on a directory not working correctly #1142

alanshaw opened this issue Dec 11, 2017 · 7 comments · Fixed by #1143 or #1148
Assignees
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P1 High: Likely tackled by core team if no one steps up

Comments

@alanshaw
Copy link
Member

alanshaw commented Dec 11, 2017

  • Version: 0.27.3
  • Platform: macOS 10.13.1
  • Subsystem: files

Type:

Bug

Severity:

High

Description:

ipfs cat on a directory displays the contents of a file in a sub directory, not the error "this dag node is a directory"

Steps to reproduce the error:

$ jsipfs init
initializing ipfs node at /Users/alan/.jsipfs
generating 2048-bit RSA keypair...done
peer identity: QmU8eJXWVYudzSrV5fxQuptmK1haqMG6E1eKP47xuF4e1K
to get started, enter:

	 jsipfs files cat /ipfs/QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr/readme

lets cat that directory:

$ jsipfs cat QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr
WIP

# 0.0 - Introduction

Welcome to IPFS! This tour will guide you through a few of the
features of this tool, and the most common commands. Then, it will
immerse you into the world of merkledags and the amazing things
you can do with them.

...

Wait, I was expecting some sort of directory error...

$ ipfs cat QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr
Error: this dag node is a directory

...yeah like that

$ ipfs cat QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr/tour/0.0-intro
WIP

# 0.0 - Introduction

Welcome to IPFS! This tour will guide you through a few of the
features of this tool, and the most common commands. Then, it will
immerse you into the world of merkledags and the amazing things
you can do with them.

...

weirdness, it is displaying a file in a sub folder...

@daviddias daviddias added exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P1 High: Likely tackled by core team if no one steps up labels Dec 11, 2017
@daviddias
Copy link
Member

This is an issue on js-ipfs-unixfs-engine. @pgte is this something you could take a look? Also, let's make sure to add a test to interface-ipfs-core.

@pgte pgte self-assigned this Dec 12, 2017
@pgte
Copy link
Contributor

pgte commented Dec 12, 2017

On it.

@pgte
Copy link
Contributor

pgte commented Dec 12, 2017

Tests here: ipfs-inactive/interface-js-ipfs-core#182

@daviddias
Copy link
Member

@alanshaw test out js-ipfs 0.27.4 and let me know how it goes :)

@alanshaw
Copy link
Member Author

alanshaw commented Dec 14, 2017

I'm getting Uncaught TypeError: Cannot read property ‘content’ of undefined when ipfs.files.cat on a directory now.

screen shot 2017-12-14 at 11 35 24

This is the hash I'm trying, which should be available in all IPFS repos:
https://ipfs.io/ipfs/QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr

daviddias pushed a commit that referenced this issue Dec 15, 2017
* fix: cat: test file existence *after* filtering. Should fix #1142

* fix: cat: filtering out result files

* fix: cat: for when the ipfs path is a buffer

* fix: cat: remove /ipfs/ prefix if there is one
richardschneider pushed a commit that referenced this issue Dec 17, 2017
* fix: cat: test file existence *after* filtering. Should fix #1142

* fix: cat: filtering out result files

* fix: cat: for when the ipfs path is a buffer

* fix: cat: remove /ipfs/ prefix if there is one
MicrowaveDev pushed a commit to galtproject/js-ipfs that referenced this issue May 22, 2020
@Usman-Qasim
Copy link

ipfs cat /ipfs/QmeZZkwN*zNgz38RBhHxmbCLH8UoUGQ*****6fcERe
Error: this dag node is a directory

Can someone tell me how to solve this issue?

let file = fs.readFileSync(path);
let varr = { path: path, content: file };
let fileAdded = await ipfs.add(varr);
let fileHash = fileAdded.cid;

@Usman-Qasim
Copy link

ipfs cat /ipfs/QmeZZkwN*_zNgz38RBhH_xmbCLH8UoUGQ*****6fcERe
Error: this dag node is a directory

Can someone tell me how to solve this issue?

let file = fs.readFileSync(path);
let varr = { path: path, content: file };
let fileAdded = await ipfs.add(varr);
let fileHash = fileAdded.cid;

ipfs cat /ipfs/QmeZZkwN*zNgz38RBhHxmbCLH8UoUGQ*****6fcERe/fileName.extenstion

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P1 High: Likely tackled by core team if no one steps up
Projects
None yet
4 participants