Skip to content

Warn about duplicate files during validation - #189

Merged
tompollard merged 3 commits into
mainfrom
feature/duplicate-file-validation
Oct 20, 2026
Merged

tompollard merged 3 commits into
mainfrom
feature/duplicate-file-validation

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Add duplicate-content warnings to the existing filesystem validation check. For each byte-identical non-empty file after the first, the warning names both paths and the SHA-256 checksum. Warnings are review prompts; no files are removed.

The validator groups files by size, compares a 64 KiB prefix, and streams the full file only for remaining candidates. It skips symbolic links, empty files, and ignored paths. Read failures are reported as warnings rather than silently treated as a clean result.

Researchers can disable this check with physionet validate --no-duplicate-check or ValidationConfig(check_duplicate_files=False) when hashing large matching files would be too costly. README usage is included.

Addresses #170.

Verification

  • pytest -q: 265 passed, 1 skipped
  • flake8 ... --select=E9,F63,F7,F82,F401: passed
  • git diff --check: passed
  • Tests cover nested duplicate paths, same-size distinct files, matching prefixes with different tails, ignored/empty/symlink files, unreadable candidates, Python opt-out, and CLI JSON output.

- Move should_ignore to config.py so the validator and the filesystem
  check use one copy.
- Report files that cannot be read as "Could not read file", whether or
  not the duplicate check is on. Hashing failures keep their own message.
- For files no larger than the 64 KiB prefix, reuse the prefix hash as
  the full hash instead of reading the file again.
Integrity, quality and privacy matched ignore patterns as substrings of
the full path, so "*.csv" never matched and a pattern could match a
folder above the dataset. They now apply should_ignore to each folder
and file name below the dataset root, like the filesystem check and
dataset stats.
@tompollard
tompollard merged commit ea30861 into main Oct 20, 2026
2 checks passed
@tompollard
tompollard deleted the feature/duplicate-file-validation branch October 20, 2026 20:18
@tompollard tompollard mentioned this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant