-
-
Notifications
You must be signed in to change notification settings - Fork 443
Prevent overwriting existing libraries and platforms at first IDE start-up #1169
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
121aa67
move initialization of libs and platforms into new contribution
42283ba
use noOverwrite when install built-in libraries and platform
9236f2e
catch errors when installing platforms and libraries at first start-up
1b214e7
arduino-cli version 0.25.0-rc1
cd9719e
refine platforms and libraries initialization in case of errors
6c4482f
add trailing newline when libraries and platform installation fail
68bc78a
use regex to check error if builtin library dependencies are already …
28b5732
rename contribution
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
arduino-ide-extension/src/browser/contributions/init-libs-platforms.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { LocalStorageService } from '@theia/core/lib/browser'; | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { BoardsService, LibraryService } from '../../common/protocol'; | ||
import { Contribution } from './contribution'; | ||
|
||
@injectable() | ||
export class InitLibsPlatforms extends Contribution { | ||
@inject(LocalStorageService) | ||
private readonly localStorageService: LocalStorageService; | ||
@inject(BoardsService) | ||
private readonly boardsService: BoardsService; | ||
@inject(LibraryService) | ||
private readonly libraryService: LibraryService; | ||
|
||
override async onReady(): Promise<void> { | ||
const isFirstStartup = !(await this.localStorageService.getData( | ||
InitLibsPlatforms.INIT_LIBS_AND_PACKAGES | ||
)); | ||
if (isFirstStartup) { | ||
await this.localStorageService.setData( | ||
InitLibsPlatforms.INIT_LIBS_AND_PACKAGES, | ||
true | ||
); | ||
const avrPackage = await this.boardsService.getBoardPackage({ | ||
id: 'arduino:avr', | ||
}); | ||
const builtInLibrary = ( | ||
await this.libraryService.search({ | ||
query: 'Arduino_BuiltIn', | ||
}) | ||
)[0]; | ||
|
||
if (avrPackage) { | ||
try { | ||
await this.boardsService.install({ | ||
item: avrPackage, | ||
noOverwrite: true, // We don't want to automatically replace custom platforms the user might already have in place | ||
}); | ||
} catch {} // If this fails, we still want to install the libraries | ||
} | ||
if (builtInLibrary) { | ||
try { | ||
await this.libraryService.install({ | ||
item: builtInLibrary, | ||
installDependencies: true, | ||
noOverwrite: true, // We don't want to automatically replace custom libraries the user might already have in place | ||
}); | ||
} catch {} | ||
} | ||
} | ||
} | ||
} | ||
export namespace InitLibsPlatforms { | ||
export const INIT_LIBS_AND_PACKAGES = 'initializedLibsAndPackages'; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you changed the logic with the
try{} catch{}
; why do not IDE2 sets this flag after the installation.Potential issue:
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is expected in my opinion.
As @per1234 stated here above:
This, I believe, means that we should try to install built-in cores and libraries only once (during the first start-up), even if the installation fails because of pre-existing installations.
Does it make sense?
If we all agree with the behavior above, then I see no value in moving the setting of INIT_LIBS_AND_PACKAGES after the installation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another use case:
If this is expected, please proceed with the merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just doing some investigation into this.
As Akos mentioned, there are two distinct types of failure during this process:
The installation should never be attempted again in the event of the former type of failure, but the IDE does really need to eventually be able to handle the latter gracefully. That could be in the form of clearly communicating about the problem to the user and leaving it up to them to use Boards and Library Manager to make the failed installations, or handling it automatically by trying again on the next restart.
The lack of handling for the latter type of failure was a pre-existing issue, so it is only the former type of failure that is of direct concern to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense! But in that case, moving the initialization of INIT_LIBS_AND_PACKAGES is not enough. I will work on a fix! Thanks!