diff --git a/cmd/db_cleanup.go b/cmd/db_cleanup.go index fdd1ff89..fdb14967 100644 --- a/cmd/db_cleanup.go +++ b/cmd/db_cleanup.go @@ -20,7 +20,7 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error { // collect information about references packages... existingPackageRefs := debian.NewPackageRefList() - context.progress.Printf("Loading mirrors and snapshots...\n") + context.progress.Printf("Loading mirrors, local repos and snapshots...\n") repoCollection := debian.NewRemoteRepoCollection(context.database) err = repoCollection.ForEach(func(repo *debian.RemoteRepo) error { err := repoCollection.LoadComplete(repo) @@ -36,6 +36,21 @@ func aptlyDbCleanup(cmd *commander.Command, args []string) error { return err } + localRepoCollection := debian.NewLocalRepoCollection(context.database) + err = localRepoCollection.ForEach(func(repo *debian.LocalRepo) error { + err := localRepoCollection.LoadComplete(repo) + if err != nil { + return err + } + if repo.RefList() != nil { + existingPackageRefs = existingPackageRefs.Merge(repo.RefList(), false) + } + return nil + }) + if err != nil { + return err + } + snapshotCollection := debian.NewSnapshotCollection(context.database) err = snapshotCollection.ForEach(func(snapshot *debian.Snapshot) error { err := snapshotCollection.LoadComplete(snapshot)