Skip to content

Commit b418443

Browse files
authored
fix: lookup snap in store and bail early if not exists in SnapInfo (#34)
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.
1 parent 61b2099 commit b418443

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/system/snap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func NewSnapFromString(snap string) *Snap {
4646
// SnapInfo returns information about a given snap, looking up details in the snap
4747
// store using the snapd client API where necessary.
4848
func (s *System) SnapInfo(snap string, channel string) (*SnapInfo, error) {
49+
// Simple check to see if the snap actually exists in the store.
50+
_, _, err := s.snapd.FindOne(snap)
51+
if err != nil {
52+
return nil, fmt.Errorf("unable to find snap '%s' in store: %w", snap, err)
53+
}
54+
4955
classic, err := s.snapIsClassic(snap, channel)
5056
if err != nil {
5157
return nil, err

0 commit comments

Comments
 (0)