From c7e18035400dc2b4e40c19d57ebaa3d411964020 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 29 Nov 2019 19:01:59 +0100 Subject: [PATCH] Fix path deletion on artifacts --- pkg/compiler/artifact.go | 8 ++++---- pkg/installer/repository.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/compiler/artifact.go b/pkg/compiler/artifact.go index f3f173ec..ea19cd77 100644 --- a/pkg/compiler/artifact.go +++ b/pkg/compiler/artifact.go @@ -36,10 +36,10 @@ import ( type ArtifactIndex []Artifact func (i ArtifactIndex) CleanPath() ArtifactIndex { - var newIndex []Artifact - copy(newIndex, i) - for _, n := range newIndex { - n.SetPath(path.Base(n.GetPath())) + newIndex := ArtifactIndex{} + for _, n := range i { + art := n.(*PackageArtifact) + newIndex = append(newIndex, &PackageArtifact{Path: path.Base(n.GetPath()), SourceAssertion: art.SourceAssertion, CompileSpec: art.CompileSpec, Dependencies: art.Dependencies}) } return newIndex //Update if exists, otherwise just create diff --git a/pkg/installer/repository.go b/pkg/installer/repository.go index 239d1d3f..c85a2e76 100644 --- a/pkg/installer/repository.go +++ b/pkg/installer/repository.go @@ -162,11 +162,12 @@ func (r *LuetRepository) GetTree() tree.Builder { func (r *LuetRepository) Write(dst string) error { os.MkdirAll(dst, os.ModePerm) + r.Index = r.Index.CleanPath() + data, err := yaml.Marshal(r) if err != nil { return err } - r.Index = r.Index.CleanPath() err = ioutil.WriteFile(filepath.Join(dst, "repository.yaml"), data, os.ModePerm) if err != nil { return err