mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix bug on compression detection when chunck < 10bytes
This commit is contained in:
parent
abf85b2508
commit
02c291d13b
1 changed files with 5 additions and 5 deletions
10
archive.go
10
archive.go
|
@ -1,7 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
|
@ -85,17 +85,17 @@ func Tar(path string, compression Compression) (io.Reader, error) {
|
||||||
|
|
||||||
func Untar(archive io.Reader, path string) error {
|
func Untar(archive io.Reader, path string) error {
|
||||||
|
|
||||||
buf := make([]byte, 10)
|
bufferedArchive := bufio.NewReaderSize(archive, 10)
|
||||||
if _, err := archive.Read(buf); err != nil {
|
buf, err := bufferedArchive.Peek(10)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
compression := DetectCompression(buf)
|
compression := DetectCompression(buf)
|
||||||
archive = io.MultiReader(bytes.NewReader(buf), archive)
|
|
||||||
|
|
||||||
utils.Debugf("Archive compression detected: %s", compression.Extension())
|
utils.Debugf("Archive compression detected: %s", compression.Extension())
|
||||||
|
|
||||||
cmd := exec.Command("tar", "-f", "-", "-C", path, "-x"+compression.Flag())
|
cmd := exec.Command("tar", "-f", "-", "-C", path, "-x"+compression.Flag())
|
||||||
cmd.Stdin = archive
|
cmd.Stdin = bufferedArchive
|
||||||
// Hardcode locale environment for predictable outcome regardless of host configuration.
|
// Hardcode locale environment for predictable outcome regardless of host configuration.
|
||||||
// (see https://github.com/dotcloud/docker/issues/355)
|
// (see https://github.com/dotcloud/docker/issues/355)
|
||||||
cmd.Env = []string{"LANG=en_US.utf-8", "LC_ALL=en_US.utf-8"}
|
cmd.Env = []string{"LANG=en_US.utf-8", "LC_ALL=en_US.utf-8"}
|
||||||
|
|
Loading…
Reference in a new issue