mirror of
https://github.com/moby/moby.git
synced 2026-07-24 16:26:51 +00:00
These comments were added to prevent users from accidentally importing using the wrong module name, but they don't have an effect when working in go modules mode. Remove the comments in preparation of moving this package to a separate module. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
846 B
Go
34 lines
846 B
Go
package chrootarchive
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"path/filepath"
|
|
|
|
"github.com/docker/docker/pkg/archive"
|
|
)
|
|
|
|
// applyLayerHandler parses a diff in the standard layer format from `layer`, and
|
|
// applies it to the directory `dest`. Returns the size in bytes of the
|
|
// contents of the layer.
|
|
func applyLayerHandler(dest string, layer io.Reader, options *archive.TarOptions, decompress bool) (size int64, err error) {
|
|
if decompress {
|
|
decompressed, err := archive.DecompressStream(layer)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
defer decompressed.Close()
|
|
|
|
layer = decompressed
|
|
}
|
|
|
|
// Ensure it is a Windows-style volume path
|
|
dest = addLongPathPrefix(filepath.Clean(dest))
|
|
s, err := archive.UnpackLayer(dest, layer, nil)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("ApplyLayer %s failed UnpackLayer to %s: %s", layer, dest, err)
|
|
}
|
|
|
|
return s, nil
|
|
}
|