Skip to content

Commit 68d37eb

Browse files
committed
Platform's installed.json is now loaded if found
1 parent a1baefc commit 68d37eb

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

arduino/cores/packagemanager/loader.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,20 @@ func (pm *PackageManager) loadPlatformRelease(platform *cores.PlatformRelease, p
265265
platform.InstallDir = path
266266

267267
// Some useful paths
268+
installedJSONPath := path.Join("installed.json")
268269
platformTxtPath := path.Join("platform.txt")
269270
platformTxtLocalPath := path.Join("platform.local.txt")
270271
programmersTxtPath := path.Join("programmers.txt")
271272

273+
// If the installed.json file is found load it, this is done to handle the
274+
// case in which the platform's index and its url have been deleted locally,
275+
// if we don't load it some information about the platform is lost
276+
if installedJSONPath.Exist() {
277+
if _, err := pm.LoadPackageIndexFromFile(installedJSONPath); err != nil {
278+
return fmt.Errorf("loading %s: %s", installedJSONPath, err)
279+
}
280+
}
281+
272282
// Create platform properties
273283
platform.Properties = platform.Properties.Clone() // TODO: why CLONE?
274284
if p, err := properties.SafeLoad(platformTxtPath.String()); err == nil {

test/test_core.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,24 @@ def test_core_search_no_args(run_command, httpserver):
6464
result = run_command("core search")
6565
assert result.ok
6666
num_platforms = 0
67+
found = False
6768
for l in result.stdout.splitlines()[1:]: # ignore the header on first line
6869
if l: # ignore empty lines
69-
assert not l.startswith("test:x86")
70+
if l.startswith("test:x86"):
71+
found = True
7072
num_platforms += 1
7173

7274
# same thing in JSON format, also check the number of platforms found is the same
7375
result = run_command("core search --format json")
7476
assert result.ok
7577
platforms = json.loads(result.stdout)
78+
found = False
79+
platforms = json.loads(result.stdout)
7680
for elem in platforms:
77-
assert elem.get("Name") != "test_core"
81+
if elem.get("Name") == "test_core":
82+
found = True
83+
break
84+
assert found
7885
assert len(platforms) == num_platforms
7986

8087
# list all with additional urls, check the test core is there

0 commit comments

Comments
 (0)