Design a duplicate-file reporter that omits unique files, verifies content equality, balances CPU and I/O work, and handles changing or unreadable files.
Explain how you would implement and test a file-duplicate reporting utility. Files without duplicates must not appear in its output; if no duplicates exist, it should produce no duplicate results.
Discuss CPU and I/O costs as well as correctness. Clarify the duplicate definition, traversal scope, output grouping/order, and policies for links, unreadable files, and files that change during a scan. The exercise supplies no complete filesystem fixture or exact output format.
### What a Strong Answer Covers
- A staged comparison strategy that avoids reading every file unnecessarily.
- A distinction between a matching fingerprint and verified equality.
- Bounded memory and concurrency for large files or many candidate files.
- Output containing only actual duplicate groups, including the no-duplicate case.
- Concrete test files and failure cases that would validate the implementation.
### Follow-up Questions
- When would more hashing workers make the scan slower rather than faster?
- How would you avoid reporting a duplicate based on a file that changed halfway through reading it?
Overview: Design a duplicate-file reporter that omits unique files, verifies content equality, balances CPU and I/O work, and handles changing or unreadable files.
Explain how you would implement and test a file-duplicate reporting utility. Files without duplicates must not appear in its output; if no duplicates exist, it should produce no duplicate results.
Discuss CPU and I/O costs as well as correctness. Clarify the duplicate definition, traversal scope, output grouping/order, and policies for links, unreadable files, and files that change during a scan. The exercise supplies no complete filesystem fixture or exact output format.
What a Strong Answer Covers Guidance
A staged comparison strategy that avoids reading every file unnecessarily.
A distinction between a matching fingerprint and verified equality.
Bounded memory and concurrency for large files or many candidate files.
Output containing only actual duplicate groups, including the no-duplicate case.
Concrete test files and failure cases that would validate the implementation.
Follow-up Questions Guidance
When would more hashing workers make the scan slower rather than faster?
How would you avoid reporting a duplicate based on a file that changed halfway through reading it?