Make sure contents don't have duplicate package entries. #142

This commit is contained in:
Andrey Smirnov
2015-04-05 21:12:25 +03:00
parent 4e3284cd98
commit d46d8de5f7

View File

@@ -3,6 +3,7 @@ package deb
import (
"fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"io"
"sort"
"strings"
@@ -56,9 +57,12 @@ func (index *ContentsIndex) WriteTo(w io.Writer) (int64, error) {
for _, path := range paths {
packages := index.index[path]
parts := make([]string, len(packages))
parts := make([]string, 0, len(packages))
for i := range packages {
parts[i] = packages[i].QualifiedName()
name := packages[i].QualifiedName()
if !utils.StrSliceHasItem(parts, name) {
parts = append(parts, name)
}
}
nn, err = fmt.Fprintf(w, "%s %s\n", path, strings.Join(parts, ","))
n += int64(nn)