... | ... |
@@ -108,7 +108,9 @@ func TarFilter(path string, compression Compression, filter []string) (io.Reader |
108 | 108 |
// identity (uncompressed), gzip, bzip2, xz. |
109 | 109 |
// FIXME: specify behavior when target path exists vs. doesn't exist. |
110 | 110 |
func Untar(archive io.Reader, path string) error { |
111 |
- |
|
111 |
+ if archive == nil { |
|
112 |
+ return fmt.Errorf("Empty archive") |
|
113 |
+ } |
|
112 | 114 |
bufferedArchive := bufio.NewReaderSize(archive, 10) |
113 | 115 |
buf, err := bufferedArchive.Peek(10) |
114 | 116 |
if err != nil { |
... | ... |
@@ -92,9 +92,11 @@ func StoreImage(img *Image, layerData Archive, root string, store bool) error { |
92 | 92 |
defer file.Close() |
93 | 93 |
layerData = file |
94 | 94 |
} |
95 |
- |
|
96 |
- if err := Untar(layerData, layer); err != nil { |
|
97 |
- return err |
|
95 |
+ // If layerData is not nil, unpack it into the new layer |
|
96 |
+ if layerData != nil { |
|
97 |
+ if err := Untar(layerData, layer); err != nil { |
|
98 |
+ return err |
|
99 |
+ } |
|
98 | 100 |
} |
99 | 101 |
|
100 | 102 |
return StoreSize(img, root) |