Untar untars the given reader into the destination directory
(fromReader io.ReadCloser, toPath string)
| 38 | |
| 39 | // Untar untars the given reader into the destination directory |
| 40 | func (u *Unarchiver) Untar(fromReader io.ReadCloser, toPath string) error { |
| 41 | defer fromReader.Close() |
| 42 | |
| 43 | fileCounter := 0 |
| 44 | gzr, err := gzip.NewReader(fromReader) |
| 45 | if err != nil { |
| 46 | return errors.Errorf("error decompressing: %v", err) |
| 47 | } |
| 48 | |
| 49 | defer gzr.Close() |
| 50 | |
| 51 | tarReader := tar.NewReader(gzr) |
| 52 | for { |
| 53 | shouldContinue, err := u.untarNext(toPath, tarReader) |
| 54 | if err != nil { |
| 55 | return errors.Wrapf(err, "decompress %s", toPath) |
| 56 | } else if !shouldContinue { |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | fileCounter++ |
| 61 | if fileCounter%500 == 0 { |
| 62 | u.log.Infof("Downstream - Untared %d files...", fileCounter) |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func (u *Unarchiver) untarNext(destPath string, tarReader *tar.Reader) (bool, error) { |
| 68 | u.syncConfig.fileIndex.fileMapMutex.Lock() |
no test coverage detected