When doing db cleanup, consider package references stored in PublishedRepos

of local repo publishes. #146
This commit is contained in:
Andrey Smirnov
2014-11-26 23:41:18 +03:00
parent 8c54e15a11
commit d9c62780c2
12 changed files with 57 additions and 9 deletions
+19 -1
View File
@@ -20,7 +20,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
// collect information about references packages...
existingPackageRefs := deb.NewPackageRefList()
context.Progress().Printf("Loading mirrors, local repos and snapshots...\n")
context.Progress().Printf("Loading mirrors, local repos, snapshots and published repos...\n")
err = context.CollectionFactory().RemoteRepoCollection().ForEach(func(repo *deb.RemoteRepo) error {
err := context.CollectionFactory().RemoteRepoCollection().LoadComplete(repo)
if err != nil {
@@ -61,6 +61,24 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error {
return err
}
err = context.CollectionFactory().PublishedRepoCollection().ForEach(func(published *deb.PublishedRepo) error {
if published.SourceKind != "local" {
return nil
}
err := context.CollectionFactory().PublishedRepoCollection().LoadComplete(published, context.CollectionFactory())
if err != nil {
return err
}
for _, component := range published.Components() {
existingPackageRefs = existingPackageRefs.Merge(published.RefList(component), false)
}
return nil
})
if err != nil {
return err
}
// ... and compare it to the list of all packages
context.Progress().Printf("Loading list of all packages...\n")
allPackageRefs := context.CollectionFactory().PackageCollection().AllPackageRefs()