Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipfs object diff returns a change when diffing empty directory with itself #4591

Closed
rememberberry opened this issue Jan 18, 2018 · 3 comments
Labels
kind/bug A bug in existing code (including security flaws) topic/commands Topic commands

Comments

@rememberberry
Copy link

Version information:

go-ipfs version: 0.4.13-
Repo version: 6
System version: amd64/darwin
Golang version: go1.9.2

Type:

Bug

Severity:

Low

Description:

To recreate:
ipfs files mkdir /testdir
HASH=$(ipfs files stat --hash /testdir)
ipfs object diff $HASH $HASH
output is:

~ QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn ""

I would expect it to be empty

@Stebalien
Copy link
Member

I can confirm. This is definitely a bug...

@Stebalien Stebalien added kind/bug A bug in existing code (including security flaws) topic/commands Topic commands labels Jan 18, 2018
@schomatis
Copy link
Contributor

@Stebalien I'd like to work on this if no one is.

The Diff algorithm seems to be designed to work with directories as inputs, comparing its links, not with single files (or an empty directory, that for this case behaves the same). The base case of this recursive function is assuming (my interpretation) that if it reached that node in the tree it's because they (version A and B) had different hashes in the parent node (directory) that led it to them, and hence they are different (so it returns it as a modification in the tree). It is not contemplating the case where the algorithm starts at the leaf (single file, empty directory). I think that base case should be modified to take that into account.

@schomatis
Copy link
Contributor

@rememberberry Could you check again with #4767 please?

ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this issue Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) topic/commands Topic commands
Projects
None yet
Development

No branches or pull requests

3 participants