ipfs.add() Seemingly produces random results when adding a directory that contains a .jpeg
See original GitHub issueThe 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:
- Created 6 years ago
- Comments:5
Top GitHub Comments
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!
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.