question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ipfs.add() Seemingly produces random results when adding a directory that contains a .jpeg

See original GitHub issue

The following code seems to produce random results:

boolean flag = false;
		while(!flag){
		addResult = ipfs.add(file);
		System.out.println(addResult.size());
		for(MerkleNode mn: addResult){
			System.out.println(mn.name);
			if(mn.name.get().equals("home")){
				flag = true;
			}
		}
		}

example output:

.jpeg included in directory:

5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 12 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home/Zexamples/Zexample] Optional[home/Zexamples] Optional[home/examples+in+examples/examples+in+examples+in+examples] Optional[home/examples+in+examples] Optional[home]

2nd run: 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 12 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home/Zexamples/Zexample] Optional[home/Zexamples] Optional[home/examples+in+examples/examples+in+examples+in+examples] Optional[home/examples+in+examples] Optional[home]

3rd run:

5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 5 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] 12 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home/Zexamples/Zexample] Optional[home/Zexamples] Optional[home/examples+in+examples/examples+in+examples+in+examples] Optional[home/examples+in+examples] Optional[home]

results from a smaller directory (just an example text file. the .jpeg, and the undo.txt file which just contains the previous hash from my /ipns/peerid:

2 Optional[home/example] Optional[home/trifocal.jpeg] 4 Optional[home/example] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home]

2nd run on same smaller dir: 1 Optional[home/example] 4 Optional[home/example] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home]

3rd run on same smaller dir:

1 Optional[home/example] 2 Optional[home/example] Optional[home/trifocal.jpeg] 2 Optional[home/example] Optional[home/trifocal.jpeg] 1 Optional[home/example] 4 Optional[home/example] Optional[home/trifocal.jpeg] Optional[home/undo.txt] Optional[home]

run with the .jpeg removed from the dir: 11 Optional[home/examples+in+examples/examples+in+examples+in+examples/Exampleception] Optional[home/examples+in+examples/Examples%5E2] Optional[home/hello.txt] Optional[home/hello2.txt] Optional[home/hello3] Optional[home/undo.txt] Optional[home/Zexamples/Zexample] Optional[home/Zexamples] Optional[home/examples+in+examples/examples+in+examples+in+examples] Optional[home/examples+in+examples] Optional[home]

run on smaller dir with jpeg removed:

3 Optional[home/example] Optional[home/undo.txt] Optional[home]

add() seems to have no issues adding simple text files but something is wonky with adding pics.

I will post updates to this as i try other file formats (png,mp4 are mainly the two other file types i plan on trying)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Restaldtcommented, Sep 5, 2018

From what I remember I was having to make sure the add got all the way to the root directory of “home” so that it actually added all of the files in that directory which is what that while loop checked for. So if it tried to add the directory without having made it to the root the loop continued on until it found all of the files in that "home"directory. I honestly don’t think I even changed anything and it just eventually started working correctly so this may have been a bug with IPFS itsself that got fixed.

I did find the code for that project and running it now it seems like it doesn’t ever need multiple loops to get to that root directory anymore so this seems to be fixed!

1reaction
Restaldtcommented, Sep 5, 2018

I am so sorry about this issue I don’t even remember exactly what was happening with this project or how I got around it as I was eventually able to get it working correctly. I did this project for a networking class about a year ago (I absolutely loved the idea of IPFS and this API helped me out a lot) so if i can find the code and figure out what it was doing wrong I will try to recreate this issue but until then I am going to close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's really happening when you add a file to IPFS? - Medium
Basically, we take the raw content (in this case, a cat photo), and run that data through a hash function, to produce a...
Read more >
Discuss: improving `ipfs.add` · Issue #3033 - GitHub
ipfs.add lets you pass collections of FileContent and collections of FileObject (that have associated paths). This leads to some behaviors:.
Read more >
How to create a directory and add files to ipfs using js-ipfs with ...
Full working example to create a directory path and add a file to it ... nodeId = 'ipfs-' + Math.random() const node =...
Read more >
Regular Files API (Lesson 5) - IPFS Tutorial - ProtoSchool
When we added files to IPFS in Lesson 3, we saw that the add and addAll methods returned ... as we saw previously,...
Read more >
Search Results - CVE
CVE-2022-44653, A security agent directory traversal vulnerability in Trend Micro ... While the plugin added a .jpg extension to all uploaded filenames, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found