-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Directory.CreateDirectory: create missing parents using default UnixFileMode. #74002
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsFixes #73899. @jozkee @adamsitnik @eerhardt @dotnet/area-system-io ptal.
|
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory_UnixFileMode.Unix.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, pending resolving the open comments and assuming the CI passes.
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.cs
Outdated
Show resolved
Hide resolved
There are test failures in runtime-extra-platforms and they seem related to this PR. Note: In case you don't know how to retrieve the logs for mobile platforms, here are instructions: Instructions
Example: All the failures seem to be the same for the 4 CI legs where they showed up:
The tests fail here:
Callstacks
|
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
I'm going to make another change here based on the discussion with @jozkee (#74002 (comment)).
|
|
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Show resolved
Hide resolved
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.cs
Outdated
Show resolved
Hide resolved
// Apply permissions to an existing directory when we're overwriting metadata | ||
// or the directory was created as a missing parent (stored in pendingModes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the directory existed prior to TarFile.ExtractToDirectory()
, with overwrite:false
we don't throw exception? Documentation for overwriteFiles param says otherwise:
true to overwrite files and directories in destinationDirectoryName; false to avoid overwriting, and throw if any files or directories are found with existing names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
The behavior is the same as tar
. When not passing the --overwrite
flag, t doesn't give an error when extracting a directory that already exists, and it does set the mode of that directory.
const UnixFileMode ExtractPermissions = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute; | ||
|
||
Debug.Assert(pendingModes is not null); | ||
|
||
if (Directory.Exists(fullPath)) | ||
{ | ||
// Apply permissions to an existing directory when we're overwriting metadata | ||
// or the directory was created as a missing parent (stored in pendingModes). | ||
// Apply permissions to an existing directory. | ||
if (mode.HasValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know tar
overwrites metadata for existing directories by default, but it feels counterintuitive for our API to do that when overwriteFiles
is false
. I really don't know what's best here.
if (mode.HasValue) | |
if (mode.HasValue && overwriteMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tar
has this behavior.
--overwrite
Overwrite existing files when extracting.
--overwrite-dir
Overwrite metadata of existing directories when extracting (default).
--overwrite
control in .NET is through overwrite
.
.NET doesn't have an arg for --overwrite-dir
but the behavior matches with the tar
default.
I think we're good.
I pushed the whitespace change before the Android platforms ran and they got cancelled. |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
CI issues on extra-platforms are not related to System.Formats.Tar nor System.IO.Directory. |
/backport to release/7.0-rc1 |
Started backporting to release/7.0-rc1: https://github.com/dotnet/runtime/actions/runs/2892175875 |
Fixes #73899.
@jozkee @adamsitnik @eerhardt @dotnet/area-system-io ptal.