Skip to content

Commit

Permalink
fix: lookup snap in store and bail early if not exists in SnapInfo (#34)
Browse files Browse the repository at this point in the history
This is a simple fix that ensures that non-existent snaps don't get
repeatedly looked up with the retry mechanism used to establish more
detailed Snap information.

The primary motivation for this is failing fast rather than keeping
the user waiting if they specify a non-existent snap.
  • Loading branch information
jnsgruk authored Feb 3, 2025
1 parent 61b2099 commit b418443
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/system/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ func NewSnapFromString(snap string) *Snap {
// SnapInfo returns information about a given snap, looking up details in the snap
// store using the snapd client API where necessary.
func (s *System) SnapInfo(snap string, channel string) (*SnapInfo, error) {
// Simple check to see if the snap actually exists in the store.
_, _, err := s.snapd.FindOne(snap)
if err != nil {
return nil, fmt.Errorf("unable to find snap '%s' in store: %w", snap, err)
}

classic, err := s.snapIsClassic(snap, channel)
if err != nil {
return nil, err
Expand Down

0 comments on commit b418443

Please sign in to comment.