mafintosh/tar-fs

Preserve file UID/GID when creating an archive

cristianrgreco opened this issue · 1 comments

Hello

I'm having an issue preserving the UID/GID of a file in an archive.

For example, I have the file /tmp.test.txt which has a UID/GID of 1250:1250:

➜  ls -n ~/tmp/test.txt
-rw-r--r--  1 1250  1250  0 13 Jul 10:31 /tmp/test.txt

I am creating a tar with this file, but when I inspect it, the UID/GID has been set to 0:0:

const tar = archiver("tar");
tar.file("/tmp.test.txt", { name: "/tmp/test.txt" });
tar.finalize();
tar.pipe(fs.createWriteStream("/tmp/test.tar"));
➜  tar --numeric-owner -tvf /tmp/test.tar
-rw-r--r--  0 0      0           0 13 Jul 10:31 tmp/test.txt

My understanding is that a tar archive should preserve file ownership information. Apologies if I've misunderstood/missing something. Any help appreciated

Something to notice is, if the UID/GID change to 0:0 then is changing to superuser 🤔