Skip to content

feat: support template bundles as zip archives #11839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Buffer
  • Loading branch information
mtojek committed Jan 26, 2024
commit af8a0d55c08abbfb08066f429d2013bc0064124e
14 changes: 11 additions & 3 deletions coderd/fileszip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"archive/tar"
"archive/zip"
"bytes"
"errors"
"io"
)

const zipCopyBufferSize = 4096

func createTarFromZip(zipReader *zip.Reader) ([]byte, error) {
var tarBuffer bytes.Buffer

Expand Down Expand Up @@ -40,9 +43,14 @@ func processFileInZipArchive(zipFile *zip.File, tarWriter *tar.Writer) error {
return err
}

_, err = io.Copy(tarWriter, zipFileReader)
if err != nil {
return err
for {
_, err := io.CopyN(tarWriter, zipFileReader, zipCopyBufferSize)
if err != nil {
if errors.Is(err, io.EOF) {
break
}
return err
}
}
return nil
}