Skip to content
Snippets Groups Projects
Commit 290b1973 authored by Solomon Hykes's avatar Solomon Hykes
Browse files

Fix a bug which caused creation of empty images (and volumes) to crash. FIxes #995.

parent ecd1fff9
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment