Skip to content

Tar: ExtendedAttributes does not synchronize with public properties of PaxTarEntry #76405

Open
@jozkee

Description

@jozkee

Description

There's no syncronization between ExtendedAttributes and public properties, which may lead to unexpected results when writing a PaxTarEntry. And when the entry is written, we always take the value from the properties, which is better than the opposite IMO.

Reproduction Steps

[Fact]
public void QuickTest()
{
    Dictionary<string, string> ea = new();
    ea["path"] = "foo";

    PaxTarEntry paxEntry = new PaxTarEntry(TarEntryType.RegularFile, "bar", ea);

    Console.WriteLine(paxEntry.Name); // prints bar
    Console.WriteLine(paxEntry.ExtendedAttributes["path"]); // prints foo
}

Expected behavior

I would expect an exception when you pass an ExtendedAttributes dictionary with a key that colides with a pulbic property AND the values are different.
Also, I would expect that setting the value on any of them would update the other. I think you can just set values through the public properties e.g: Name, LinkName, GroupName, etc. but we need to double-check.

Actual behavior

No syncronization nor exception is thrown when this happens.

Regression?

No

Known Workarounds

This is more relevant for the "path" key and you can lookup the key in the dictionary before passing it to the ctor. and use that for the entryName argument.

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions