Skip to content

Fix hashing of directories #6113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rcannood
Copy link
Contributor

@rcannood rcannood commented May 22, 2025

Files.walkFileTree does not guarantee any specific order for iterating over files within a directory:

Considerations When Creating a FileVisitor

A file tree is walked depth first, but you cannot make any assumptions about the iteration order that subdirectories are visited.

-- source

This causes the sha of HashBuilder.hashDirSha256 to be different in certain situations (#6112).

This PR fixes the issue by storing all of the (path, sha256) in an array list, sorting by path, and then passing them to the hasher.

Notes:

  • The code in preVisitDirectory seems like it would cause a null pointer exception if the condition (base != null) is false -- so maybe base is always not null? What should happen in this code chuck if base does happen to be null?
  • It's hard to add a unit test for this, since the issue only arises in very specific situations.

Copy link

netlify bot commented May 22, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 92a96d4
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/682f6902718c0800082df261

rcannood and others added 2 commits May 22, 2025 19:52
Signed-off-by: Robrecht Cannoodt <[email protected]>
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.

Incorrect hash when staging repository directory
1 participant