Fix nested directory creation issue in hash metadata storage #3067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where
azcopy sync
would fail when syncing files in nested directory structures when using--local-hash-storage-mode HiddenFiles
.Problem
When syncing files located in nested directories (e.g.,
lib/MIME/Type.pm
wherelib
contains only theMIME
subdirectory), azcopy would fail with:This occurred because the
getHashPath()
method inHiddenFileDataAdapter
usedos.Mkdir()
which only creates a single directory level, not the full path recursively.Solution
Replace
os.Mkdir()
withos.MkdirAll()
to create the full directory path recursively. This ensures that all necessary parent directories are created before attempting to write the hash metadata file.Changes
common/hash_data_adapter_hidden_files.go
: Changedos.Mkdir()
toos.MkdirAll()
in thegetHashPath()
method (2 lines changed)common/hash_data_adapter_hidden_files_test.go
: Comprehensive test cases to validate the fix and prevent regressionTesting
Added test cases that reproduce the exact scenario described in the issue:
TestHiddenFileDataAdapter_NestedDirectories
: Tests nested directory structure likelib/MIME/Type.pm
TestHiddenFileDataAdapter_IssueScenario
: Tests the specific directory structure from the GitHub issueAll tests pass and the build remains successful.
Fixes #3017.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.