Set path during recipe load

Set path only when the recipe is loaded and not when it gets converted. In such way the internal temporary db knows where the sources where.
This commit is contained in:
Ettore Di Giacinto 2019-11-04 17:14:32 +01:00
parent b32a6c2286
commit 61c318d549
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C
2 changed files with 9 additions and 10 deletions

View File

@ -102,7 +102,10 @@ type DefaultPackage struct {
PackageConflicts []*DefaultPackage `json:"conflicts"` // Affects YAML field names too.
IsSet bool `json:"set"` // Affects YAML field names too.
Path string `json:"-"` // primary key with auto increment
// TODO: Annotations?
// Path is set only internally when tree is loaded from disk
Path string `json:"path,omitempty"` // primary key with auto increment
}
// State represent the package state

View File

@ -86,22 +86,18 @@ func (r *Recipe) Load(path string) error {
dat, err := ioutil.ReadFile(currentpath)
if err != nil {
return err
return errors.Wrap(err, "Error reading file "+currentpath)
}
pack, err := pkg.DefaultPackageFromYaml(dat)
if err != nil {
return err
return errors.Wrap(err, "Error reading yaml "+currentpath)
}
pack.SetPath(filepath.Dir(path))
// Path is set only internally when tree is loaded from disk
pack.SetPath(filepath.Dir(currentpath))
_, err = r.Tree().GetPackageSet().CreatePackage(&pack)
if err != nil {
return err
}
// first thing to do, check error. and decide what to do about it
if err != nil {
return err
return errors.Wrap(err, "Error creating package "+pack.GetName())
}
return nil