From f7fcccf0a192b4e758fd3ae881a4b1cc1bf2d309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Fri, 28 Feb 2020 21:10:31 +0100 Subject: [PATCH] Allow only satisfied dependencies to appear as a leaf node --- pkg/migrate/main.go | 53 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/pkg/migrate/main.go b/pkg/migrate/main.go index 23eede57b..64ae7a574 100644 --- a/pkg/migrate/main.go +++ b/pkg/migrate/main.go @@ -190,34 +190,35 @@ func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error { for len(m.Leafs) > 0 { for i := len(m.Leafs) - 1; i >= 0; i-- { n := m.Leafs[i] - // only nodes with satisfied deps can be migrated - if n.Satisfied() { - - // migrate & update leaf nodes - add, err := n.Migrate(repoRecord, users) - if err != nil { - return err - } - - // this will maintain order - copy(m.Leafs[i:], m.Leafs[i+1:]) - m.Leafs = m.Leafs[:len(m.Leafs)-1] - - // update leaf nodes (entry points) - // take care to not duplicate the given nodes. - // That would be a bit not optimal :) - for _, a := range add { - for _, n := range m.Leafs { - if a.Compare(n) { - goto skip - } - } - - m.Leafs = append(m.Leafs, a) - skip: - } + // migrate & update leaf nodes + add, err := n.Migrate(repoRecord, users) + if err != nil { + return err } + + // this will maintain order + copy(m.Leafs[i:], m.Leafs[i+1:]) + m.Leafs = m.Leafs[:len(m.Leafs)-1] + + // update leaf nodes (entry points) + // take care to not duplicate the given nodes. + // That would be a bit not optimal :) + for _, a := range add { + for _, n := range m.Leafs { + if a.Compare(n) { + goto skip + } + } + + // only include satisfied nodes, as only they can be processed + if a.Satisfied() { + m.Leafs = append(m.Leafs, a) + } + + skip: + } + } }