Closed
Description
When traversing the contents of a Tar Archive, there doesn't appear to be a way to access the reference to which a sym link points. The TarEntry structure indicates that the type is symlink
, but there is no other metadata with information about where the sym link points.
import { join } from "https://deno.land/[email protected]/path/mod.ts";
import { ensureDir, ensureFile } from "https://deno.land/[email protected]/fs/mod.ts";
import { copy } from "https://deno.land/[email protected]/streams/mod.ts";
import { Untar } from "https://deno.land/[email protected]/archive/mod.ts";
export async function extractTarArchive(archive: string, destination: string) {
const reader = await Deno.open(archive, { read: true });
const untar = new Untar(reader);
for await (const entry of untar) {
if (entry.type === "symlink") {
console.log(entry);
continue;
}
if (entry.type === "directory") {
await ensureDir(join(destination, entry.fileName));
continue;
}
await ensureFile(join(destination, entry.fileName));
const file = await Deno.open(join(destination, entry.fileName), {
write: true,
});
await copy(entry, file);
}
}
extractTarArchive("tarball.tar", "output_folder");
Here is a snippet that will attempt to read the contents of a Tar Archive. If it encounters a symlink
it prints the metadata, but there doesn't appear to be a way to see what the sym link points too. In the case of a symlink I see this:
TarEntry {
fileName: "folder/linked_file.txt",
fileMode: 493,
mtime: 1677876636,
uid: 501,
gid: 20,
owner: "irbull",
group: "staff",
type: "symlink",
fileSize: 0
}
This link_file.txt
should point to file.txt
. I've attached a tar archive that includes a sym link. (sorry, I had to zip the tar archive, as GitHub doesn't accept .tar
files.)
Metadata
Metadata
Assignees
Labels
No labels