Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove duplicate paths from the etc exports #379

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions util/provider/share/share_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,31 @@ func cleanLine(line, lineCheck string) string {
}
goodPaths = append(goodPaths, path)
}
goodPaths = removeDuplicates(goodPaths)
return fmt.Sprintf("\"%s\" %s", strings.Join(goodPaths, "\" \""), lineCheck)
}

// takes a set of paths and removes duplicates as well as cleaning up any child paths
func removeDuplicates(paths []string) []string {
rtn := []string{}
// look through the paths
for i, path := range paths {

for j, originalPath := range paths {

// if im looking at the same path then ignore it
if i == j {
continue
}

// if i find an element that is shorter but the same directory structure
// ignore the child directory
if strings.HasPrefix(path, originalPath) {
continue
}

rtn = append(rtn, path)
}
}
return rtn
}