Make also deps recalculation concurrent

This commit is contained in:
Ettore Di Giacinto
2019-11-01 16:26:03 +01:00
parent eef03f8909
commit ef1d0e5573
5 changed files with 60 additions and 23 deletions

View File

@@ -123,6 +123,22 @@ func (db *BoltDatabase) GetPackages() []string {
return ids
}
func (db *BoltDatabase) GetAllPackages(packages chan Package) error {
bolt, err := storm.Open(db.Path)
if err != nil {
return err
}
defer bolt.Close()
// Fetching records one by one (useful when the bucket contains a lot of records)
query := bolt.Select()
return query.Each(new(DefaultPackage), func(record interface{}) error {
u := record.(*DefaultPackage)
packages <- u
return err
})
}
// Encode encodes the package to string.
// It returns an ID which can be used to retrieve the package later on.
func (db *BoltDatabase) CreatePackage(p Package) (string, error) {