Compress compresses the given files and folders into a tar archive
(writer io.WriteCloser, files []string)
| 197 | |
| 198 | // Compress compresses the given files and folders into a tar archive |
| 199 | func (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 |
| 223 | func (d *Downstream) Ping(context.Context, *remote.Empty) (*remote.Empty, error) { |
no test coverage detected