func subtractWhiteouts(pathWhitelist []string, whiteouts []string) []string { matchPaths := []string{} for _, path := range pathWhitelist { // If one of the parent dirs of the current path matches the // whiteout then also this path should be removed curPath := path for curPath != "/" { for _, whiteout := range whiteouts { if curPath == whiteout { matchPaths = append(matchPaths, path) } } curPath = filepath.Dir(curPath) } } for _, matchPath := range matchPaths { idx := util.IndexOf(pathWhitelist, matchPath) if idx != -1 { pathWhitelist = append(pathWhitelist[:idx], pathWhitelist[idx+1:]...) } } sort.Sort(sort.StringSlice(pathWhitelist)) return pathWhitelist }
func subtractWhiteouts(pathWhitelist []string, whiteouts []string) []string { for _, whiteout := range whiteouts { idx := util.IndexOf(pathWhitelist, whiteout) if idx != -1 { pathWhitelist = append(pathWhitelist[:idx], pathWhitelist[idx+1:]...) } } return pathWhitelist }