daemon/job/build_jobs: fix validateReceivingSidesDoNotOverlap

This commit is contained in:
Matthias Freund 2020-01-30 01:59:57 +01:00 committed by Christian Schwarz
parent cca95f613b
commit 4ba85c40cc
2 changed files with 6 additions and 0 deletions

View File

@ -104,6 +104,11 @@ func validateReceivingSidesDoNotOverlap(receivingRootFSs []string) error {
sort.Slice(rfss, func(i, j int) bool {
return strings.Compare(rfss[i], rfss[j]) == -1
})
// add tailing slash because of hierarchy-simulation
// rootfs/ is not root of rootfs2/
for i := 0; i < len(rfss); i++ {
rfss[i] += "/"
}
// idea:
// no path in rfss must be prefix of another
//

View File

@ -18,6 +18,7 @@ func TestValidateReceivingSidesDoNotOverlap(t *testing.T) {
{false, []string{"a"}},
{false, []string{"some/path"}},
{false, []string{"zroot/sink1", "zroot/sink2", "zroot/sink3"}},
{false, []string{"zroot/foo", "zroot/foobar"}},
{true, []string{"zroot/b", "zroot/b"}},
{true, []string{"zroot/foo", "zroot/foo/bar", "zroot/baz"}},
{false, []string{"a/x", "b/x"}},