Skip to content

Linux: Tar archive file root path is not stripped from file paths #580

@sensslen

Description

@sensslen

Steps to reproduce

  1. Create a new Tar Archive stream
  2. Set the RootPath to the path to the Path to be added
  3. Add the folder to be added
    var destinationFile = Path.Combine(Path.GetTempPath(), "output.tar");
    using var outStream = File.OpenWrite(destinationFile);
    using var tarArchive = TarArchive.CreateOutputTarArchive(outStream);

    var srcPath= "/tmp/subpath1";
    tarArchive.RootPath = srcPath;

    var tarEntry = TarEntry.CreateEntryFromFile(srcPath);
    tarArchive.WriteEntry(tarEntry, recurse: true);

Note this happens on Linux and not on Windows

Expected behavior

$ tar -tf /tmp/output.tar
subpath2/file1
subpath2/subpath3/file2

Actual behavior

$ tar -tf /tmp/output.tar
tmp/subpath1/subpath2/file1
tmp/subpath1/subpath2/subpath3/file2

Version of SharpZipLib

1.3.1

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions