You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.)
I had to modify a copy of archive/untar.ts to expose the linkName property on the TarEntry type in order to work around this issue (extracting tar files containing symbolic links). If there is interest (I know that there is a lot of talk about changing the archive module to use streams -- #1985 -- so changes to the old version may not be welcome), I could contribute it back here.
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.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:This
link_file.txt
should point tofile.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.)tarball.tar.zip
The text was updated successfully, but these errors were encountered: