Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion arduino/cores/packagemanager/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) []*status.
statuses = append(statuses, errs...)
}
}
// If the Package does not contain Platforms or Tools we remove it since does not contain anything valuable
if len(targetPackage.Platforms) == 0 && len(targetPackage.Tools) == 0 {
delete(pm.Packages, packager)
}
}

return statuses
Expand Down Expand Up @@ -262,7 +266,6 @@ func (pm *PackageManager) loadPlatform(targetPackage *cores.Package, platformPat
// case: ARCHITECTURE/VERSION/boards.txt
// let's dive into VERSION directories

platform := targetPackage.GetOrCreatePlatform(architecture)
versionDirs, err := platformPath.ReadDir()
if err != nil {
return status.Newf(codes.FailedPrecondition, tr("reading dir %[1]s: %[2]s"), platformPath, err)
Expand All @@ -280,6 +283,7 @@ func (pm *PackageManager) loadPlatform(targetPackage *cores.Package, platformPat
if err != nil {
return status.Newf(codes.FailedPrecondition, tr("invalid version dir %[1]s: %[2]s"), versionDir, err)
}
platform := targetPackage.GetOrCreatePlatform(architecture)
release := platform.GetOrCreateRelease(version)
if err := pm.loadPlatformRelease(release, versionDir); err != nil {
return status.Newf(codes.FailedPrecondition, tr("loading platform release %[1]s: %[2]s"), release, err)
Expand Down
21 changes: 12 additions & 9 deletions commands/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
for _, platform := range targetPackage.Platforms {
platformRelease := packageManager.GetInstalledPlatformRelease(platform)

// The All flags adds to the list of installed platforms the installable platforms (from the indexes)
// If both All and UpdatableOnly are set All takes precedence
if req.All {
installedVersion := ""
if platformRelease == nil {
if platformRelease == nil { // if the platform is not installed
platformRelease = platform.GetLatestRelease()
} else {
installedVersion = platformRelease.Version.String()
}
rpcPlatform := commands.PlatformReleaseToRPC(platform.GetLatestRelease())
rpcPlatform.Installed = installedVersion
res = append(res, rpcPlatform)
continue
// it could happen, especially with indexes not perfectly compliant with specs that a platform do not contain a valid release
if platformRelease != nil {
rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
rpcPlatform.Installed = installedVersion
res = append(res, rpcPlatform)
continue
}
}

if platformRelease != nil {
Expand All @@ -58,10 +62,9 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
return nil, &arduino.PlatformNotFoundError{Platform: platform.String(), Cause: fmt.Errorf(tr("the platform has no releases"))}
}

if req.UpdatableOnly {
if latest == platformRelease {
continue
}
// show only the updatable platforms
if req.UpdatableOnly && latest == platformRelease {
continue
}

rpcPlatform := commands.PlatformReleaseToRPC(platformRelease)
Expand Down
Loading