mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-19 19:28:22 +00:00
Show progress when loading packages from reflist.
This commit is contained in:
@@ -37,7 +37,7 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
||||
context.progress.Printf("Loading packages...\n")
|
||||
|
||||
packageCollection := debian.NewPackageCollection(context.database)
|
||||
list, err := debian.NewPackageListFromRefList(repo.RefList(), packageCollection)
|
||||
list, err := debian.NewPackageListFromRefList(repo.RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ func aptlyRepoMoveCopyImport(cmd *commander.Command, args []string) error {
|
||||
context.progress.Printf("Loading packages...\n")
|
||||
|
||||
packageCollection := debian.NewPackageCollection(context.database)
|
||||
dstList, err := debian.NewPackageListFromRefList(dstRepo.RefList(), packageCollection)
|
||||
dstList, err := debian.NewPackageListFromRefList(dstRepo.RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
srcList, err := debian.NewPackageListFromRefList(srcRefList, packageCollection)
|
||||
srcList, err := debian.NewPackageListFromRefList(srcRefList, packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func aptlyRepoRemove(cmd *commander.Command, args []string) error {
|
||||
context.progress.Printf("Loading packages...\n")
|
||||
|
||||
packageCollection := debian.NewPackageCollection(context.database)
|
||||
list, err := debian.NewPackageListFromRefList(repo.RefList(), packageCollection)
|
||||
list, err := debian.NewPackageListFromRefList(repo.RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
|
||||
|
||||
// Convert snapshot to package list
|
||||
context.progress.Printf("Loading packages (%d)...\n", snapshot.RefList().Len()+source.RefList().Len())
|
||||
packageList, err := debian.NewPackageListFromRefList(snapshot.RefList(), packageCollection)
|
||||
packageList, err := debian.NewPackageListFromRefList(snapshot.RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
sourcePackageList, err := debian.NewPackageListFromRefList(source.RefList(), packageCollection)
|
||||
sourcePackageList, err := debian.NewPackageListFromRefList(source.RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ func aptlySnapshotVerify(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
packageList, err := debian.NewPackageListFromRefList(snapshots[0].RefList(), packageCollection)
|
||||
context.progress.Printf("Loading packages...\n")
|
||||
|
||||
packageList, err := debian.NewPackageListFromRefList(snapshots[0].RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
@@ -43,7 +45,7 @@ func aptlySnapshotVerify(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
for i := 1; i < len(snapshots); i++ {
|
||||
pL, err := debian.NewPackageListFromRefList(snapshots[i].RefList(), packageCollection)
|
||||
pL, err := debian.NewPackageListFromRefList(snapshots[i].RefList(), packageCollection, context.progress)
|
||||
if err != nil {
|
||||
fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
14
debian/list.go
vendored
14
debian/list.go
vendored
@@ -2,6 +2,7 @@ package debian
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -49,7 +50,7 @@ func NewPackageList() *PackageList {
|
||||
}
|
||||
|
||||
// NewPackageListFromRefList loads packages list from PackageRefList
|
||||
func NewPackageListFromRefList(reflist *PackageRefList, collection *PackageCollection) (*PackageList, error) {
|
||||
func NewPackageListFromRefList(reflist *PackageRefList, collection *PackageCollection, progress aptly.Progress) (*PackageList, error) {
|
||||
// empty reflist
|
||||
if reflist == nil {
|
||||
return NewPackageList(), nil
|
||||
@@ -57,14 +58,25 @@ func NewPackageListFromRefList(reflist *PackageRefList, collection *PackageColle
|
||||
|
||||
result := &PackageList{packages: make(map[string]*Package, reflist.Len())}
|
||||
|
||||
if progress != nil {
|
||||
progress.InitBar(int64(reflist.Len()), false)
|
||||
}
|
||||
|
||||
err := reflist.ForEach(func(key []byte) error {
|
||||
p, err := collection.ByKey(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load package with key %s: %s", key, err)
|
||||
}
|
||||
if progress != nil {
|
||||
progress.AddBar(1)
|
||||
}
|
||||
return result.Add(p)
|
||||
})
|
||||
|
||||
if progress != nil {
|
||||
progress.ShutdownBar()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
2
debian/publish.go
vendored
2
debian/publish.go
vendored
@@ -105,7 +105,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage
|
||||
}
|
||||
|
||||
// Load all packages
|
||||
list, err := NewPackageListFromRefList(p.snapshot.RefList(), packageCollection)
|
||||
list, err := NewPackageListFromRefList(p.snapshot.RefList(), packageCollection, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load packages: %s", err)
|
||||
}
|
||||
|
||||
6
debian/reflist_test.go
vendored
6
debian/reflist_test.go
vendored
@@ -46,18 +46,18 @@ func (s *PackageRefListSuite) TestNewPackageListFromRefList(c *C) {
|
||||
|
||||
reflist := NewPackageRefListFromPackageList(s.list)
|
||||
|
||||
_, err := NewPackageListFromRefList(reflist, coll)
|
||||
_, err := NewPackageListFromRefList(reflist, coll, nil)
|
||||
c.Assert(err, ErrorMatches, "unable to load package with key.*")
|
||||
|
||||
coll.Update(s.p5)
|
||||
coll.Update(s.p6)
|
||||
|
||||
list, err := NewPackageListFromRefList(reflist, coll)
|
||||
list, err := NewPackageListFromRefList(reflist, coll, nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(list.Len(), Equals, 4)
|
||||
c.Check(list.Add(s.p4), ErrorMatches, "conflict in package.*")
|
||||
|
||||
list, err = NewPackageListFromRefList(nil, coll)
|
||||
list, err = NewPackageListFromRefList(nil, coll, nil)
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(list.Len(), Equals, 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user