Skip to content

Commit fb2aede

Browse files
committed
fix(coderd): add trailing path separator to dir entries when converting to zip
1 parent 134189a commit fb2aede

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

coderd/fileszip.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func WriteZipArchive(w io.Writer, tarReader *tar.Reader) error {
9494
return err
9595
}
9696
zipHeader.Name = tarHeader.Name
97+
// Some versions of unzip do not check the mode on a file entry and
98+
// simply assume that entries with a trailing path separator (/) are
99+
// directories, and that everything else is a file. Give them a hint.
100+
if tarHeader.FileInfo().IsDir() && !strings.HasSuffix(tarHeader.Name, "/") {
101+
zipHeader.Name += "/"
102+
}
97103

98104
zipEntry, err := zipWriter.CreateHeader(zipHeader)
99105
if err != nil {

0 commit comments

Comments
 (0)