Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve installed.json handling in v2/tools #983

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

MatteoPologruto
Copy link
Contributor

@MatteoPologruto MatteoPologruto commented Aug 1, 2024

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • Tests for the changes have been added (for bug fixes / features)
  • What kind of change does this PR introduce?

Code enhancement

  • What is the current behavior?

The installed.json is read everytime it needs to be updated and there is no mutex policy to prevent file corruption.

  • What is the new behavior?

Information from installed.json is stored in a map and a mutex policy is introduced.

  • Does this PR introduce a breaking change?

No

  • Other information:

@MatteoPologruto MatteoPologruto added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Aug 1, 2024
@MatteoPologruto MatteoPologruto self-assigned this Aug 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.

Project coverage is 20.70%. Comparing base (6287df1) to head (33f59b5).

Files Patch % Lines
v2/pkgs/tools.go 88.46% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #983      +/-   ##
==========================================
+ Coverage   20.01%   20.70%   +0.68%     
==========================================
  Files          42       42              
  Lines        2568     2565       -3     
==========================================
+ Hits          514      531      +17     
+ Misses       1968     1949      -19     
+ Partials       86       85       -1     
Flag Coverage Δ
unit 20.70% <89.65%> (+0.68%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MatteoPologruto MatteoPologruto marked this pull request as ready for review August 1, 2024 14:25
@MatteoPologruto MatteoPologruto linked an issue Aug 1, 2024 that may be closed by this pull request
v2/pkgs/tools.go Outdated Show resolved Hide resolved
v2/pkgs/tools.go Outdated Show resolved Hide resolved
@Xayton
Copy link
Contributor

Xayton commented Aug 5, 2024

Before merging, we also need to add some code that, if the installed.json file is not parsable, it will delete it and retry, instead of panicking.

@Xayton Xayton added this to the 1.6.1 milestone Aug 5, 2024
@MatteoPologruto
Copy link
Contributor Author

MatteoPologruto commented Aug 5, 2024

Before merging, we also need to add some code that, if the installed.json file is not parsable, it will delete it and retry, instead of panicking.

This commit solves this issue. The installed.json is parsed only when the Tools struct is initialized and errors are ignored. If the json is corrupted, the installed map remains empty and any tool is downloaded from scratch, rewriting the installed.json file.

@Xayton Xayton removed this from the 1.6.1 milestone Aug 5, 2024
@MatteoPologruto MatteoPologruto merged commit a679bf3 into arduino:main Aug 5, 2024
20 checks passed
@MatteoPologruto MatteoPologruto deleted the corrupted-json-fix branch August 5, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent error while installing tools (installed.json corruption)
4 participants