-
Notifications
You must be signed in to change notification settings - Fork 741
Determine Azure directories more accurately using metadata and blob properties #6428
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
adamrtalbot
wants to merge
9
commits into
master
Choose a base branch
from
6427_determine_azure_directories_more_accurately
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6cc7cc5
Determine Azure directories more accurately using metadata and blob p…
adamrtalbot 5e0709c
Merge branch 'master' into 6427_determine_azure_directories_more_accu…
adamrtalbot 78ff466
Fix: More accurate Azure directory detection in AzFileAttributes
adamrtalbot 7b93b04
fix method signature for Azure uploadWithResponse
adamrtalbot 4b3971a
test: fix AzNioTest to create directory markers with hdi_isfolder met…
adamrtalbot 3c931af
Merge branch 'master' into 6427_determine_azure_directories_more_accu…
adamrtalbot eb16a3a
Fix test for AzFileAttributes: add unit test for trailing slash direc…
adamrtalbot 4dfec66
Fix Azure directory detection: treat only explicit trailing slash as …
adamrtalbot b90fab7
fix(azure): improve directory detection in AzFileAttributes
adamrtalbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,23 +58,42 @@ class AzFileAttributes implements BasicFileAttributes { | |
| objectId = "/${client.containerName}/${client.blobName}" | ||
| creationTime = time(props.getCreationTime()) | ||
| updateTime = time(props.getLastModified()) | ||
| directory = client.blobName.endsWith('/') | ||
| size = props.getBlobSize() | ||
|
|
||
| // Support for Azure Data Lake Storage Gen2 with hierarchical namespace enabled | ||
|
|
||
| // Determine if this is a directory using metadata only (most reliable): | ||
| final meta = props.getMetadata() | ||
| if( meta.containsKey("hdi_isfolder") && size == 0 ){ | ||
| directory = meta.get("hdi_isfolder") | ||
| if( meta != null && meta.containsKey("hdi_isfolder") && meta.get("hdi_isfolder") == "true" ){ | ||
| directory = true | ||
| size = 0 | ||
| } | ||
| else { | ||
| // Without metadata, default to treating as file | ||
| // This aligns with Azure SDK's approach where explicit directory markers are required | ||
| directory = false | ||
| size = props.getBlobSize() | ||
adamrtalbot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| AzFileAttributes(String containerName, BlobItem item) { | ||
| objectId = "/${containerName}/${item.name}" | ||
| directory = item.name.endsWith('/') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bentsherman what will break if we incorrectly classify something as a file when it's a pseudo-directory? What's the impact of getting it wrong? |
||
| if( !directory ) { | ||
| creationTime = time(item.properties.getCreationTime()) | ||
| updateTime = time(item.properties.getLastModified()) | ||
| size = item.properties.getContentLength() | ||
|
|
||
| // Determine if this is a directory using reliable methods only: | ||
| // 1. Check if it's marked as a prefix (virtual directory) - Most reliable | ||
| if( item.isPrefix() != null && item.isPrefix() ) { | ||
| directory = true | ||
| // Virtual directories don't have properties like creation time | ||
| size = 0 | ||
| } | ||
| // 2. Check metadata for hierarchical namespace (ADLS Gen2) | ||
| else if( item.getMetadata() != null && item.getMetadata().containsKey("hdi_isfolder") && item.getMetadata().get("hdi_isfolder") == "true" ) { | ||
| directory = true | ||
| size = 0 | ||
| } | ||
| // 3. Default: treat as file | ||
| else { | ||
| directory = false | ||
| creationTime = time(item.getProperties().getCreationTime()) | ||
| updateTime = time(item.getProperties().getLastModified()) | ||
| size = item.getProperties().getContentLength() | ||
adamrtalbot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
|
|
||
1 change: 1 addition & 0 deletions
1
plugins/nf-azure/src/test/nextflow/cloud/azure/nio/AzFileAttributesTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.