Unverified Commit 63289ba6 authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

[skip-changelog] Small cosmetic fix (#1105)

* Removed unused return error in cores.Platform.GetOrCreateRelease

* cosmetic: renamed variables in commands/bundled_tools_serial_discovery.go

* fixed typo

* Renamed mutex -> listBoardMutex
parent 0ccf27f9
...@@ -112,13 +112,13 @@ func (dep *ToolDependency) String() string { ...@@ -112,13 +112,13 @@ func (dep *ToolDependency) String() string {
// GetOrCreateRelease returns the specified release corresponding the provided version, // GetOrCreateRelease returns the specified release corresponding the provided version,
// or creates a new one if not found. // or creates a new one if not found.
func (platform *Platform) GetOrCreateRelease(version *semver.Version) (*PlatformRelease, error) { func (platform *Platform) GetOrCreateRelease(version *semver.Version) *PlatformRelease {
tag := "" tag := ""
if version != nil { if version != nil {
tag = version.String() tag = version.String()
} }
if release, ok := platform.Releases[tag]; ok { if release, ok := platform.Releases[tag]; ok {
return release, nil return release
} }
release := &PlatformRelease{ release := &PlatformRelease{
Version: version, Version: version,
...@@ -128,7 +128,7 @@ func (platform *Platform) GetOrCreateRelease(version *semver.Version) (*Platform ...@@ -128,7 +128,7 @@ func (platform *Platform) GetOrCreateRelease(version *semver.Version) (*Platform
Platform: platform, Platform: platform,
} }
platform.Releases[tag] = release platform.Releases[tag] = release
return release, nil return release
} }
// FindReleaseWithVersion returns the specified release corresponding the provided version, // FindReleaseWithVersion returns the specified release corresponding the provided version,
......
...@@ -210,10 +210,7 @@ func (inPlatformRelease indexPlatformRelease) extractPlatformIn(outPackage *core ...@@ -210,10 +210,7 @@ func (inPlatformRelease indexPlatformRelease) extractPlatformIn(outPackage *core
if err != nil { if err != nil {
return fmt.Errorf("invalid platform archive size: %s", err) return fmt.Errorf("invalid platform archive size: %s", err)
} }
outPlatformRelease, err := outPlatform.GetOrCreateRelease(inPlatformRelease.Version) outPlatformRelease := outPlatform.GetOrCreateRelease(inPlatformRelease.Version)
if err != nil {
return fmt.Errorf("creating release: %s", err)
}
outPlatformRelease.IsTrusted = trusted outPlatformRelease.IsTrusted = trusted
outPlatformRelease.Resource = &resources.DownloadResource{ outPlatformRelease.Resource = &resources.DownloadResource{
ArchiveFileName: inPlatformRelease.ArchiveFileName, ArchiveFileName: inPlatformRelease.ArchiveFileName,
......
...@@ -210,10 +210,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir ...@@ -210,10 +210,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
} }
platform := targetPackage.GetOrCreatePlatform(architecture) platform := targetPackage.GetOrCreatePlatform(architecture)
release, err := platform.GetOrCreateRelease(version) release := platform.GetOrCreateRelease(version)
if err != nil {
return fmt.Errorf("loading platform release: %s", err)
}
release.IsIDEBundled = isIDEBundled release.IsIDEBundled = isIDEBundled
if isIDEBundled { if isIDEBundled {
pm.Log.Infof("Package is built-in") pm.Log.Infof("Package is built-in")
...@@ -246,10 +243,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir ...@@ -246,10 +243,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
if err != nil { if err != nil {
return fmt.Errorf("invalid version dir %s: %s", versionDir, err) return fmt.Errorf("invalid version dir %s: %s", versionDir, err)
} }
release, err := platform.GetOrCreateRelease(version) release := platform.GetOrCreateRelease(version)
if err != nil {
return fmt.Errorf("loading platform release %s: %s", versionDir, err)
}
if err := pm.loadPlatformRelease(release, versionDir); err != nil { if err := pm.loadPlatformRelease(release, versionDir); err != nil {
return fmt.Errorf("loading platform release %s: %s", versionDir, err) return fmt.Errorf("loading platform release %s: %s", versionDir, err)
} }
......
...@@ -32,14 +32,13 @@ import ( ...@@ -32,14 +32,13 @@ import (
) )
var ( var (
mutex = sync.Mutex{} serialDiscoveryVersion = semver.ParseRelaxed("1.1.0")
sdVersion = semver.ParseRelaxed("1.1.0") serialDiscoveryFlavors = []*cores.Flavor{
flavors = []*cores.Flavor{
{ {
OS: "i686-pc-linux-gnu", OS: "i686-pc-linux-gnu",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_32bit.tar.bz2", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_32bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_32bit.tar.bz2", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_32bit.tar.bz2", serialDiscoveryVersion),
Size: 1589443, Size: 1589443,
Checksum: "SHA-256:e60fa16da2735f80410c636234a405bd1cc9306090cab4e312c4189e38f93f72", Checksum: "SHA-256:e60fa16da2735f80410c636234a405bd1cc9306090cab4e312c4189e38f93f72",
CachePath: "tools", CachePath: "tools",
...@@ -48,8 +47,8 @@ var ( ...@@ -48,8 +47,8 @@ var (
{ {
OS: "x86_64-pc-linux-gnu", OS: "x86_64-pc-linux-gnu",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_64bit.tar.bz2", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_64bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_64bit.tar.bz2", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_64bit.tar.bz2", serialDiscoveryVersion),
Size: 1611875, Size: 1611875,
Checksum: "SHA-256:6232f852543094e9f73e1994e6888646fdcd24eca15fd4e5bde716a8e23046dc", Checksum: "SHA-256:6232f852543094e9f73e1994e6888646fdcd24eca15fd4e5bde716a8e23046dc",
CachePath: "tools", CachePath: "tools",
...@@ -58,8 +57,8 @@ var ( ...@@ -58,8 +57,8 @@ var (
{ {
OS: "i686-mingw32", OS: "i686-mingw32",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_32bit.zip", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_32bit.zip", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_32bit.zip", serialDiscoveryVersion),
Size: 1719070, Size: 1719070,
Checksum: "SHA-256:3efdc744a0ca11c5f9088525eb4363e90e2b6a43a0db23c5c6975a10d739c7cb", Checksum: "SHA-256:3efdc744a0ca11c5f9088525eb4363e90e2b6a43a0db23c5c6975a10d739c7cb",
CachePath: "tools", CachePath: "tools",
...@@ -68,8 +67,8 @@ var ( ...@@ -68,8 +67,8 @@ var (
{ {
OS: "x86_64-mingw32", OS: "x86_64-mingw32",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_64bit.zip", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_64bit.zip", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Windows_64bit.zip", serialDiscoveryVersion),
Size: 1683799, Size: 1683799,
Checksum: "SHA-256:c6296b92459160f4c0bf7d2e1234cd53fd64f44cb3fa8c3a4b10dd6670466c69", Checksum: "SHA-256:c6296b92459160f4c0bf7d2e1234cd53fd64f44cb3fa8c3a4b10dd6670466c69",
CachePath: "tools", CachePath: "tools",
...@@ -78,8 +77,8 @@ var ( ...@@ -78,8 +77,8 @@ var (
{ {
OS: "x86_64-apple-darwin", OS: "x86_64-apple-darwin",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_macOS_64bit.tar.bz2", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_macOS_64bit.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_macOS_64bit.tar.bz2", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_macOS_64bit.tar.bz2", serialDiscoveryVersion),
Size: 1620346, Size: 1620346,
Checksum: "SHA-256:4052a64dd68090726247dea7f03656eae951549df9878362dcedfcef116a9e9f", Checksum: "SHA-256:4052a64dd68090726247dea7f03656eae951549df9878362dcedfcef116a9e9f",
CachePath: "tools", CachePath: "tools",
...@@ -88,8 +87,8 @@ var ( ...@@ -88,8 +87,8 @@ var (
{ {
OS: "arm-linux-gnueabihf", OS: "arm-linux-gnueabihf",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM.tar.bz2", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM.tar.bz2", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM.tar.bz2", serialDiscoveryVersion),
Size: 1511104, Size: 1511104,
Checksum: "SHA-256:fe68fd5abdfebe0f01c48c3eac16d27af46ec2391da87de44571e6ea2dab31e7", Checksum: "SHA-256:fe68fd5abdfebe0f01c48c3eac16d27af46ec2391da87de44571e6ea2dab31e7",
CachePath: "tools", CachePath: "tools",
...@@ -98,8 +97,8 @@ var ( ...@@ -98,8 +97,8 @@ var (
{ {
OS: "arm64-linux-gnueabihf", OS: "arm64-linux-gnueabihf",
Resource: &resources.DownloadResource{ Resource: &resources.DownloadResource{
ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM64.tar.bz2", sdVersion), ArchiveFileName: fmt.Sprintf("serial-discovery_v%s_Linux_ARM64.tar.bz2", serialDiscoveryVersion),
URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM64.tar.bz2", sdVersion), URL: fmt.Sprintf("https://downloads.arduino.cc/tools/serial-discovery_v%s_Linux_ARM64.tar.bz2", serialDiscoveryVersion),
Size: 1500998, Size: 1500998,
Checksum: "SHA-256:1e6bcb6b7790d38863df15395c96baba239cb56233d7ef2d78bcb2b3efb1bc5d", Checksum: "SHA-256:1e6bcb6b7790d38863df15395c96baba239cb56233d7ef2d78bcb2b3efb1bc5d",
CachePath: "tools", CachePath: "tools",
...@@ -123,12 +122,14 @@ type eventJSON struct { ...@@ -123,12 +122,14 @@ type eventJSON struct {
Ports []*BoardPort `json:"ports"` Ports []*BoardPort `json:"ports"`
} }
var listBoardMutex sync.Mutex
// ListBoards foo // ListBoards foo
func ListBoards(pm *packagemanager.PackageManager) ([]*BoardPort, error) { func ListBoards(pm *packagemanager.PackageManager) ([]*BoardPort, error) {
// ensure the connection to the discoverer is unique to avoid messing up // ensure the connection to the discoverer is unique to avoid messing up
// the messages exchanged // the messages exchanged
mutex.Lock() listBoardMutex.Lock()
defer mutex.Unlock() defer listBoardMutex.Unlock()
// get the bundled tool // get the bundled tool
t, err := getBuiltinSerialDiscoveryTool(pm) t, err := getBuiltinSerialDiscoveryTool(pm)
...@@ -233,8 +234,8 @@ func WatchListBoards(pm *packagemanager.PackageManager) (<-chan *discovery.Event ...@@ -233,8 +234,8 @@ func WatchListBoards(pm *packagemanager.PackageManager) (<-chan *discovery.Event
func getBuiltinSerialDiscoveryTool(pm *packagemanager.PackageManager) (*cores.ToolRelease, error) { func getBuiltinSerialDiscoveryTool(pm *packagemanager.PackageManager) (*cores.ToolRelease, error) {
builtinPackage := pm.Packages.GetOrCreatePackage("builtin") builtinPackage := pm.Packages.GetOrCreatePackage("builtin")
ctagsTool := builtinPackage.GetOrCreateTool("serial-discovery") serialDiscoveryTool := builtinPackage.GetOrCreateTool("serial-discovery")
ctagsRel := ctagsTool.GetOrCreateRelease(sdVersion) serialDiscoveryToolRel := serialDiscoveryTool.GetOrCreateRelease(serialDiscoveryVersion)
ctagsRel.Flavors = flavors serialDiscoveryToolRel.Flavors = serialDiscoveryFlavors
return pm.Package("builtin").Tool("serial-discovery").Release(sdVersion).Get() return pm.Package("builtin").Tool("serial-discovery").Release(serialDiscoveryVersion).Get()
} }
...@@ -115,7 +115,7 @@ func (instance *CoreInstance) checkForBuiltinTools(downloadCB DownloadProgressCB ...@@ -115,7 +115,7 @@ func (instance *CoreInstance) checkForBuiltinTools(downloadCB DownloadProgressCB
return err return err
} }
// Check for bultin serial-discovery tool // Check for builtin serial-discovery tool
serialDiscoveryTool, _ := getBuiltinSerialDiscoveryTool(instance.PackageManager) serialDiscoveryTool, _ := getBuiltinSerialDiscoveryTool(instance.PackageManager)
serialDiscoveryInstalled, err := instance.installToolIfMissing(serialDiscoveryTool, downloadCB, taskCB) serialDiscoveryInstalled, err := instance.installToolIfMissing(serialDiscoveryTool, downloadCB, taskCB)
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment