[#951] adm: Check for error when reading contracts from archive
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
3f1961157e
commit
67b3002743
1 changed files with 7 additions and 4 deletions
|
@ -122,11 +122,11 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
|
||||||
}
|
}
|
||||||
|
|
||||||
r := tar.NewReader(gr)
|
r := tar.NewReader(gr)
|
||||||
for h, err := r.Next(); ; h, err = r.Next() {
|
var h *tar.Header
|
||||||
if err != nil {
|
for h, err = r.Next(); err == nil && h != nil; h, err = r.Next() {
|
||||||
break
|
if h.Typeflag != tar.TypeReg {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, _ := filepath.Split(h.Name)
|
dir, _ := filepath.Split(h.Name)
|
||||||
ctrName := filepath.Base(dir)
|
ctrName := filepath.Base(dir)
|
||||||
|
|
||||||
|
@ -149,6 +149,9 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
|
||||||
}
|
}
|
||||||
m[ctrName] = cs
|
m[ctrName] = cs
|
||||||
}
|
}
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
|
return nil, fmt.Errorf("can't read contracts from archive: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
for ctrName, cs := range m {
|
for ctrName, cs := range m {
|
||||||
if cs.RawNEF == nil {
|
if cs.RawNEF == nil {
|
||||||
|
|
Loading…
Reference in a new issue