Skip to content

Commit

Permalink
Support long names in tarfs (#1933)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettgu10 committed May 13, 2024
1 parent c1ab557 commit 3a73eaf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pyodide/internal/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ export function parseTarInfo() {
let directory = root;
const buf = new Uint8Array(512);
let offset = 0;
let longName = null; // if truthy, overwrites the filename of the next header
while (true) {
Reader.read(offset, buf);
const info = decodeHeader(buf);
if (isNaN(info.mode)) {
// Invalid mode means we're done
return [root, soFiles];
}
if(longName) {
info.path = longName;
info.name = longName;
longName = null;
}
const contentsOffset = offset + 512;
offset += 512 * Math.ceil(info.size / 512 + 1);
if (info.path === "") {
Expand All @@ -79,6 +85,12 @@ export function parseTarInfo() {
// Our tar files shouldn't have these anyways...
continue;
}
if (info.type === "L") {
const buf = new Uint8Array(info.size);
Reader.read(contentsOffset, buf);
longName = decodeString(buf);
continue;
}

// Navigate to the correct directory by going up until we're at the common
// ancestor of the current position and the target then back down.
Expand Down

0 comments on commit 3a73eaf

Please sign in to comment.