Skip to content

Commit a73f7a3

Browse files
committed
Fixed NPE on 'lib upgrade' command
1 parent 8b52e80 commit a73f7a3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

commands/lib/upgrade.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,19 @@ func LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, downloadCB rpc.Downloa
4848
func LibraryUpgrade(ctx context.Context, req *rpc.LibraryUpgradeRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
4949
lm := commands.GetLibraryManager(req)
5050

51-
// get the libs to upgrade
52-
lib := filterByName(listLibraries(lm, true, true), req.GetName())
51+
// Get the library to upgrade
52+
name := req.GetName()
53+
lib := filterByName(listLibraries(lm, false, false), name)
54+
if lib == nil {
55+
// library not installed...
56+
return &arduino.LibraryNotFoundError{Library: name}
57+
}
58+
if lib.Available == nil {
59+
taskCB(&rpc.TaskProgress{Message: tr("Library %s is already at the latest version", name), Completed: true})
60+
return nil
61+
}
5362

54-
// do it
63+
// Install update
5564
return upgrade(lm, []*installedLib{lib}, downloadCB, taskCB)
5665
}
5766

0 commit comments

Comments
 (0)