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

Method Untar

pkg/devspace/sync/tar.go:40–65  ·  view source on GitHub ↗

Untar untars the given reader into the destination directory

(fromReader io.ReadCloser, toPath string)

Source from the content-addressed store, hash-verified

38
39// Untar untars the given reader into the destination directory
40func (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
67func (u *Unarchiver) untarNext(destPath string, tarReader *tar.Reader) (bool, error) {
68 u.syncConfig.fileIndex.fileMapMutex.Lock()

Callers 1

initDownloadMethod · 0.80

Calls 4

untarNextMethod · 0.95
CloseMethod · 0.65
ErrorfMethod · 0.45
InfofMethod · 0.45

Tested by

no test coverage detected