better-files icon indicating copy to clipboard operation
better-files copied to clipboard

Do not depend on hashing for directory equality

Open pathikrit opened this issue 8 years ago • 2 comments

There is a small chance of md5 collisions so, don't depend on it for comparing two directory structures

pathikrit avatar Oct 10 '15 20:10 pathikrit

What would be the proper fix to this? Are you suggesting equality on absolute paths?

If you add links to places of the codebase where this can be fixed, I'll make sure we tackle this one in the next Scala Center hackathon :wink:.

jvican avatar Mar 07 '17 22:03 jvican

I honestly think this is fine - we check if 2 directories are equal if their md5s are equal. in better-files, we get a deterministic md5 for directory by recursively listing and hashing a directory. This is almost impossible to have a false positive unless we find an md5 hash.

That being said, the correct way would be to recursively list both (but an iterator not actually load all the recursive paths in memory) and zip these 2 iterators and compare them one by one...

The code to look at is File.isSimilarContent

pathikrit avatar Mar 07 '17 22:03 pathikrit