better-files
better-files copied to clipboard
Do not depend on hashing for directory equality
There is a small chance of md5 collisions so, don't depend on it for comparing two directory structures
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:.
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