MCPcopy Create free account
hub / github.com/aptly-dev/aptly / BuildDownloadQueue

Method BuildDownloadQueue

deb/remote.go:702–758  ·  view source on GitHub ↗

BuildDownloadQueue builds queue, discards current PackageList

(packagePool aptly.PackagePool, packageCollection *PackageCollection, checksumStorage aptly.ChecksumStorage, skipExistingPackages, latestOnly bool)

Source from the content-addressed store, hash-verified

700
701// BuildDownloadQueue builds queue, discards current PackageList
702func (repo *RemoteRepo) BuildDownloadQueue(packagePool aptly.PackagePool, packageCollection *PackageCollection, checksumStorage aptly.ChecksumStorage, skipExistingPackages, latestOnly bool) (queue []PackageDownloadTask, downloadSize int64, err error) {
703 if repo.packageList == nil {
704 err = fmt.Errorf("package list is empty, please (re)download package indexes")
705 return
706 }
707
708 if latestOnly {
709 repo.packageList, err = repo.packageList.FilterLatest()
710 if err != nil {
711 return
712 }
713 }
714
715 queue = make([]PackageDownloadTask, 0, repo.packageList.Len())
716 seen := make(map[string]int, repo.packageList.Len())
717
718 err = repo.packageList.ForEach(func(p *Package) error {
719 if repo.packageRefs != nil && skipExistingPackages {
720 if repo.packageRefs.Has(p) {
721 // skip this package, but load checksums/files from package in DB
722 var prevP *Package
723 prevP, err = packageCollection.ByKey(p.Key(""))
724 if err != nil {
725 return err
726 }
727
728 p.UpdateFiles(prevP.Files())
729 return nil
730 }
731 }
732
733 list, err2 := p.DownloadList(packagePool, checksumStorage)
734 if err2 != nil {
735 return err2
736 }
737
738 for _, task := range list {
739 key := task.File.DownloadURL()
740 idx, found := seen[key]
741 if !found {
742 queue = append(queue, task)
743 downloadSize += task.File.Checksums.Size
744 seen[key] = len(queue) - 1
745 } else {
746 // hook up the task to duplicate entry already on the list
747 queue[idx].Additional = append(queue[idx].Additional, task)
748 }
749 }
750
751 return nil
752 })
753 if err != nil {
754 return
755 }
756
757 return
758}
759

Callers 8

TestDownloadMethod · 0.80
TestDownloadFlatMethod · 0.80
aptlyMirrorUpdateFunction · 0.80
apiMirrorsUpdateFunction · 0.80

Calls 10

FilesMethod · 0.95
FilterLatestMethod · 0.80
ByKeyMethod · 0.80
UpdateFilesMethod · 0.80
DownloadListMethod · 0.80
DownloadURLMethod · 0.80
LenMethod · 0.45
ForEachMethod · 0.45
HasMethod · 0.45
KeyMethod · 0.45

Tested by 6

TestDownloadMethod · 0.64
TestDownloadFlatMethod · 0.64