From 8f991ed7e851d32edb7195d91c7c498186fde92f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 21 Jul 2022 15:32:32 +0200 Subject: [PATCH 1/2] packagemanager: Show size difference between package_index and downloaded file This will help identify the problem: - if the file is corrupted - if the package_index is wrong - if there is a bug in the CLI (more rare... but actually possible :-) --- arduino/resources/checksums.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino/resources/checksums.go b/arduino/resources/checksums.go index 58cba7a0ffc..5e816b93c28 100644 --- a/arduino/resources/checksums.go +++ b/arduino/resources/checksums.go @@ -94,7 +94,7 @@ func (r *DownloadResource) TestLocalArchiveSize(downloadDir *paths.Path) (bool, return false, fmt.Errorf(tr("getting archive info: %s"), err) } if info.Size() != r.Size { - return false, fmt.Errorf(tr("fetched archive size differs from size specified in index")) + return false, fmt.Errorf("%s: %d != %d", tr("fetched archive size differs from size specified in index"), info.Size(), r.Size) } return true, nil From 27c91d6e62119e717ed57036c25322780136ef9e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 21 Jul 2022 16:23:52 +0200 Subject: [PATCH 2/2] Load package indexes after installed packages The installed packages keeps an extract of the original package_index.json, at the moment of the installation, inside a file named installed.json. This extract may turn out useful if the original package_XXX_index.json is lost or removed to keep the platform functional. On the other hand, if the original package_XXX_index.json is modified the information kept in the installed.json may be outdated and should be replaced by the upstream index: this is the reason why it's loaded after the hardware platforms. --- commands/instances.go | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/commands/instances.go b/commands/instances.go index 79700833e3f..1b52fafd040 100644 --- a/commands/instances.go +++ b/commands/instances.go @@ -238,6 +238,27 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro return pm.LoadToolsFromPackageDir(builtinPackage, pm.PackagesDir.Join("builtin", "tools")) } + // Load Platforms + if profile == nil { + for _, err := range pm.LoadHardware() { + s := &arduino.PlatformLoadingError{Cause: err} + responseError(s.ToRPCStatus()) + } + } else { + // Load platforms from profile + errs := pm.LoadHardwareForProfile( + profile, true, downloadCallback, taskCallback, + ) + for _, err := range errs { + s := &arduino.PlatformLoadingError{Cause: err} + responseError(s.ToRPCStatus()) + } + + // Load "builtin" tools + _ = loadBuiltinTools() + } + + // Load packages index urls := []string{globals.DefaultIndexURL} if profile == nil { urls = append(urls, configuration.Settings.GetStringSlice("board_manager.additional_urls")...) @@ -265,26 +286,6 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro } } - // Load Platforms - if profile == nil { - for _, err := range pm.LoadHardware() { - s := &arduino.PlatformLoadingError{Cause: err} - responseError(s.ToRPCStatus()) - } - } else { - // Load platforms from profile - errs := pm.LoadHardwareForProfile( - profile, true, downloadCallback, taskCallback, - ) - for _, err := range errs { - s := &arduino.PlatformLoadingError{Cause: err} - responseError(s.ToRPCStatus()) - } - - // Load "builtin" tools - _ = loadBuiltinTools() - } - // We load hardware before verifying builtin tools are installed // otherwise we wouldn't find them and reinstall them each time // and they would never get reloaded.