What Building a Duplicate File Scanner for Windows Taught Me About NTFS

https://hackernoon.imgix.net/images/d2OVrbHNhdX1QyrGKXAbzId3Prt2-2793bjc.png

Hashing is the easy part. Hard links, sparse files, and a race condition that silently poisons your results are not.

Every "free up 50 GB" utility makes duplicate detection sound like a solved problem. Walk the filesystem, group by size, hash what's left, delete the extras. Three steps, one afternoon.

It is not three steps. I spent a week building one of these scanners properly, and almost none of that time went into hashing. It went into the things NTFS does that a naive implementation gets wrong — and two of those failure modes are the kind that report success while being completely incorrect.

This is what I hit, in the order I hit it.

The premise is wrong before you write a line of code

Windows has no duplicate file finder. Storage Sense is the closest built-in feature, and it explicitly does not look for duplicate content — it...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE