From 61c318d549da555d71d67eac4c8e4dbd23f4ace7 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Mon, 4 Nov 2019 17:14:32 +0100 Subject: [PATCH] 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. --- pkg/package/package.go | 5 ++++- pkg/tree/recipes.go | 14 +++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/package/package.go b/pkg/package/package.go index 83ab6197..2fc019bf 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -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 diff --git a/pkg/tree/recipes.go b/pkg/tree/recipes.go index db2a0e0b..d1411b67 100644 --- a/pkg/tree/recipes.go +++ b/pkg/tree/recipes.go @@ -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