Don't download the same files twice in one cycle.

This commit is contained in:
Andrey Smirnov
2014-01-13 00:19:45 +04:00
parent d684c87fd1
commit 1268f744ab
4 changed files with 34 additions and 4 deletions
+9 -2
View File
@@ -186,14 +186,21 @@ func (repo *RemoteRepo) Download(d utils.Downloader, packageCollection *PackageC
// Download all package files
ch := make(chan error, list.Len())
queued := make(map[string]bool, 1024)
count := 0
err = list.ForEach(func(p *Package) error {
list, err := p.DownloadList(packageRepo)
for _, pair := range list {
d.Download(repo.PackageURL(pair[0]).String(), pair[1], ch)
count++
key := pair[0] + "-" + pair[1]
_, found := queued[key]
if !found {
d.Download(repo.PackageURL(pair[0]).String(), pair[1], ch)
count++
} else {
queued[key] = true
}
}
return err