简体   繁体   中英

Python tarfile library - @PaxHeader files

I want to create an archive with Python tarfile library.

I have wanted to pack two directories: 1 , 2 .

But after executing script I get the archive with 3 directories - 1 , 2 , . .

In test.tar.gz\test.tar\.\.\ I have found many files with the same names: @PaxHeader .

Strange but when I pack directories via CLI there are not these same files.

  1. Can I pack directories without these system files via Python tarfile?
  2. What are these files?

UPDATE :

I use:

with tarfile.open(archive, 'w:gz') as tar:
    tar.add(x, x)

Maybe you can try this,add format config.

with tarfile.open(archive, 'w:gz',format=tarfile.GNU_FORMAT) as tar:
    tar.add(x, x)

As describe in tarfile library:

The default format for creating archives. This is currently PAX_FORMAT.

Changed in version 3.8: The default format for new archives was changed to PAX_FORMAT from GNU_FORMAT.

https://docs.python.org/3/library/tarfile.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM