Example #1
0
// snapUpdates identifies which snaps have updates in the store.
func snapUpdates(repo *store.SnapUbuntuStoreRepository) (snaps []*snap.Info, err error) {
	// TODO: this should eventually be snap-id based
	// NOTE this *will* send .sideload apps to the store.
	installed, err := ActiveSnapIterByType(fullNameWithChannel, snap.TypeApp, snap.TypeGadget, snap.TypeOS, snap.TypeKernel)
	if err != nil || len(installed) == 0 {
		return nil, err
	}

	rsnaps, err := repo.Updates(installed, nil)
	if err != nil {
		return nil, err
	}

	for _, rsnap := range rsnaps {
		current := ActiveSnapByName(rsnap.Name())
		if current == nil || current.Revision() != rsnap.Revision {
			snaps = append(snaps, rsnap)
		}
	}

	return snaps, nil
}