Skip to content

Commit

Permalink
zip: fix bug with readdir and trailing slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 10, 2022
1 parent 4f43888 commit c58fe49
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/fs/fs_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
// Handle a directory
lowerDir := strings.ToLower(dirPath)
if _, ok := dirs[lowerDir]; !ok {
dirs[lowerDir] = &compressedDir{
dir := &compressedDir{
path: dirPath,
entries: make(map[string]EntryKind),
}

// List the same directory both with and without the slash
dirs[lowerDir] = dir
dirs[lowerDir+"/"] = dir
}
} else {
// Handle a file
Expand All @@ -122,7 +126,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
path: dirPath,
entries: make(map[string]EntryKind),
}

// List the same directory both with and without the slash
dirs[lowerDir] = dir
dirs[lowerDir+"/"] = dir
}
dir.entries[baseName] = FileEntry
}
Expand All @@ -147,7 +154,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
path: dirPath,
entries: make(map[string]EntryKind),
}

// List the same directory both with and without the slash
dirs[lowerDir] = dir
dirs[lowerDir+"/"] = dir
}
dir.entries[baseName] = DirEntry
baseName = dirPath
Expand Down

0 comments on commit c58fe49

Please sign in to comment.