MCPcopy Index your code
hub / github.com/devspace-sh/devspace / compress

Method compress

helper/server/downstream.go:199–220  ·  view source on GitHub ↗

Compress compresses the given files and folders into a tar archive

(writer io.WriteCloser, files []string)

Source from the content-addressed store, hash-verified

197
198// Compress compresses the given files and folders into a tar archive
199func (d *Downstream) compress(writer io.WriteCloser, files []string) error {
200 defer writer.Close()
201
202 // Use compression
203 gw := gzip.NewWriter(writer)
204 defer gw.Close()
205
206 tarWriter := tar.NewWriter(gw)
207 defer tarWriter.Close()
208
209 writtenFiles := make(map[string]bool)
210 for _, path := range files {
211 if _, ok := writtenFiles[path]; !ok {
212 err := recursiveTar(d.options.RemotePath, path, writtenFiles, tarWriter, true)
213 if err != nil {
214 return errors.Wrapf(err, "compress %s", path)
215 }
216 }
217 }
218
219 return nil
220}
221
222// Ping returns empty
223func (d *Downstream) Ping(context.Context, *remote.Empty) (*remote.Empty, error) {

Callers 1

DownloadMethod · 0.95

Calls 2

recursiveTarFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected