mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix a bug which caused creation of empty images (and volumes) to crash. FIxes #995.
This commit is contained in:
parent
ecd1fff9b0
commit
290b1973a9
2 changed files with 8 additions and 4 deletions
|
@ -108,7 +108,9 @@ func TarFilter(path string, compression Compression, filter []string) (io.Reader
|
|||
// identity (uncompressed), gzip, bzip2, xz.
|
||||
// FIXME: specify behavior when target path exists vs. doesn't exist.
|
||||
func Untar(archive io.Reader, path string) error {
|
||||
|
||||
if archive == nil {
|
||||
return fmt.Errorf("Empty archive")
|
||||
}
|
||||
bufferedArchive := bufio.NewReaderSize(archive, 10)
|
||||
buf, err := bufferedArchive.Peek(10)
|
||||
if err != nil {
|
||||
|
|
8
image.go
8
image.go
|
@ -92,9 +92,11 @@ func StoreImage(img *Image, layerData Archive, root string, store bool) error {
|
|||
defer file.Close()
|
||||
layerData = file
|
||||
}
|
||||
|
||||
if err := Untar(layerData, layer); err != nil {
|
||||
return err
|
||||
// If layerData is not nil, unpack it into the new layer
|
||||
if layerData != nil {
|
||||
if err := Untar(layerData, layer); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return StoreSize(img, root)
|
||||
|
|
Loading…
Reference in a new issue