-
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
Trim file type bits from mode header #77151
Changes from 4 commits
db5f423
04bf3d0
cec85bf
6af0213
1e719fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -138,10 +138,12 @@ public string LinkName | |||
/// <remarks>The value in this field has no effect on Windows platforms.</remarks> | ||||
public UnixFileMode Mode | ||||
{ | ||||
get => (UnixFileMode)_header._mode; | ||||
// Some paths do not use the setter, and we want to return valid UnixFileMode. | ||||
// This mask only keeps the least significant 12 bits. | ||||
get => (UnixFileMode)(_header._mode & (int)TarHelpers.ValidUnixFileModes); | ||||
set | ||||
{ | ||||
if ((int)value is < 0 or > 4095) // 4095 in decimal is 7777 in octal | ||||
if ((value & ~TarHelpers.ValidUnixFileModes) != 0) // throw on invalid UnixFileModes | ||||
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. nit: There's another reference to runtime/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.File.Base.Unix.cs Line 38 in ccd9d16
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. Currently we don't have access to the helpers in the tests. 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. I was suggesting copying the |
||||
{ | ||||
throw new ArgumentOutOfRangeException(nameof(value)); | ||||
} | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,19 @@ public async Task ExtractEntry_ManySubfolderSegments_NoPrecedingDirectoryEntries | |
} | ||
} | ||
|
||
[Fact] | ||
public async Task ExtractEntry_DockerImageTarWithFileTypeInDirectoriesInMode_SuccessfullyExtracts_Async() | ||
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. I would also include a version of this test using a compressed archive since that's what the customer reported. Also, add the sync test. But this is up to you, not a big deal tbh. 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. That will require setting up token to fetch gzipped tar archive from docker api and posting a PR like dotnet/runtime-assets#279. I don't have access to those tokens (and don't think it is super important for 7.0 minimal fix). |
||
{ | ||
using (TempDirectory root = new TempDirectory()) | ||
{ | ||
await using MemoryStream archiveStream = GetTarMemoryStream(CompressionMethod.Uncompressed, "golang_tar", "docker-hello-world"); | ||
await TarFile.ExtractToDirectoryAsync(archiveStream, root.Path, overwriteFiles: true); | ||
|
||
Assert.True(File.Exists(Path.Join(root.Path, "manifest.json"))); | ||
Assert.True(File.Exists(Path.Join(root.Path, "repositories"))); | ||
} | ||
} | ||
|
||
[Theory] | ||
[InlineData(TarEntryType.SymbolicLink)] | ||
[InlineData(TarEntryType.HardLink)] | ||
|
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 wonder if not using the setter everywhere is correct. it seems somewhat inconsistent and we could've thrown earlier.
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.
Good point, I am not sure if this is intentional. I didn't wanted to go for larger refactoring at this point. There is also an existing helper:
runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.Unix.cs
Line 55 in 88aea31