mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Skip loading reflists when listing published repos
The output doesn't actually depend on the reflists, and loading them for every published repo starts to take substantial time and memory. Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
committed by
André Roth
parent
27013c0b2b
commit
8d09c202db
@@ -61,7 +61,7 @@ func apiPublishList(c *gin.Context) {
|
||||
result := make([]*deb.PublishedRepo, 0, collection.Len())
|
||||
|
||||
err := collection.ForEach(func(repo *deb.PublishedRepo) error {
|
||||
err := collection.LoadComplete(repo, collectionFactory)
|
||||
err := collection.LoadShallow(repo, collectionFactory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func aptlyPublishListTxt(cmd *commander.Command, _ []string) error {
|
||||
published := make([]string, 0, collectionFactory.PublishedRepoCollection().Len())
|
||||
|
||||
err = collectionFactory.PublishedRepoCollection().ForEach(func(repo *deb.PublishedRepo) error {
|
||||
e := collectionFactory.PublishedRepoCollection().LoadComplete(repo, collectionFactory)
|
||||
e := collectionFactory.PublishedRepoCollection().LoadShallow(repo, collectionFactory)
|
||||
if e != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error found on one publish (prefix:%s / distribution:%s / component:%s\n)",
|
||||
repo.StoragePrefix(), repo.Distribution, repo.Components())
|
||||
|
||||
@@ -277,7 +277,7 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MarshalJSON requires object to be "loaded completely"
|
||||
// MarshalJSON requires object to filled by "LoadShallow" or "LoadComplete"
|
||||
func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
|
||||
type sourceInfo struct {
|
||||
Component, Name string
|
||||
@@ -987,8 +987,11 @@ func (collection *PublishedRepoCollection) Update(repo *PublishedRepo) error {
|
||||
return batch.Write()
|
||||
}
|
||||
|
||||
// LoadComplete loads additional information for remote repo
|
||||
func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, collectionFactory *CollectionFactory) (err error) {
|
||||
// LoadShallow loads basic information on the repo's sources
|
||||
//
|
||||
// This does not *fully* load in the sources themselves and their packages.
|
||||
// It's useful if you just want to use JSON serialization without loading in unnecessary things.
|
||||
func (collection *PublishedRepoCollection) LoadShallow(repo *PublishedRepo, collectionFactory *CollectionFactory) (err error) {
|
||||
repo.sourceItems = make(map[string]repoSourceItem)
|
||||
|
||||
if repo.SourceKind == SourceSnapshot {
|
||||
@@ -999,10 +1002,6 @@ func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, col
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = collectionFactory.SnapshotCollection().LoadComplete(item.snapshot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
repo.sourceItems[component] = item
|
||||
}
|
||||
@@ -1014,6 +1013,30 @@ func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, col
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
item.packageRefs = &PackageRefList{}
|
||||
repo.sourceItems[component] = item
|
||||
}
|
||||
} else {
|
||||
panic("unknown SourceKind")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// LoadComplete loads complete information on the sources of the repo *and* their packages
|
||||
func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, collectionFactory *CollectionFactory) (err error) {
|
||||
collection.LoadShallow(repo, collectionFactory)
|
||||
|
||||
if repo.SourceKind == SourceSnapshot {
|
||||
for _, item := range repo.sourceItems {
|
||||
err = collectionFactory.SnapshotCollection().LoadComplete(item.snapshot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if repo.SourceKind == SourceLocalRepo {
|
||||
for component, item := range repo.sourceItems {
|
||||
err = collectionFactory.LocalRepoCollection().LoadComplete(item.localRepo)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -1032,13 +1055,10 @@ func (collection *PublishedRepoCollection) LoadComplete(repo *PublishedRepo, col
|
||||
}
|
||||
}
|
||||
|
||||
item.packageRefs = &PackageRefList{}
|
||||
err = item.packageRefs.Decode(encoded)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
repo.sourceItems[component] = item
|
||||
}
|
||||
} else {
|
||||
panic("unknown SourceKind")
|
||||
|
||||
Reference in New Issue
Block a user