Skip to content

Problem with built-in path normalization #263

Open
@timsueberkrueb

Description

@timsueberkrueb

I have a use case where I need to create a debian-like package format.
In a nutshell, I have to create a tar file with the following entries structure:

/./
- /./manifest
- /./control

where the root entry is indeed named .

Is there a way to create this (valid) tar file with tar-rs?
I tried different ways but failed.

What I expected to work was the following:

fn create_tar_gz(filepath: &Path, dir: &Path) -> io::Result<()> {
    let archive = std::fs::File::create(filepath)?;
    let enc = GzEncoder::new(archive, Compression::default());
    let mut tar = tar::Builder::new(enc);
    tar.append_dir_all("./.", dir)?;
    tar.finish()?;
    Ok(())

However, it creates a tar file with the following structure:

manifest
control
/./
- empty entry directory

... because the current dir component gets stripped away here:

(Component::CurDir, false) => continue,

Just changing this line to:

            (Component::CurDir, false) => {},

fixes the problem.

I have the following questions:

  1. Is there a way to create the desired tar file with the current API provided by tar-rs?
  2. If no, would a contribution be accepted for making it work and if so, what would the requirements for that be/how should that look like?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions