-
Notifications
You must be signed in to change notification settings - Fork 49
#1602: Being offline can block ide startup #1671
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
Open
maybeec
wants to merge
6
commits into
devonfw:main
Choose a base branch
from
maybeec:feature/1602-offline-startup-blocked
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
02baa14
#1602: Being offline can block ide startup
maybeec f0d7e3a
Merge branch 'main' into feature/1602-offline-startup-blocked
maybeec b9e3186
#1602: Fix platform-specific test assertion for cross-platform compat…
maybeec 279ae00
Merge branch 'feature/1602-offline-startup-blocked' of github.com:may…
maybeec 8484d31
Merge branch 'main' into feature/1602-offline-startup-blocked
maybeec 646e693
Merge branch 'main' into feature/1602-offline-startup-blocked
hohwille 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| import java.util.Collection; | ||
| import java.util.Set; | ||
|
|
||
| import com.devonfw.tools.ide.cli.CliOfflineException; | ||
| import com.devonfw.tools.ide.common.Tag; | ||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.io.FileAccess; | ||
|
|
@@ -199,8 +200,13 @@ public ToolInstallation installTool(ToolInstallRequest request) { | |
| } | ||
| } | ||
| } | ||
| performToolInstallation(request, installationPath); | ||
| return createToolInstallation(installationPath, resolvedVersion, true, processContext, additionalInstallation); | ||
| VersionIdentifier actualInstalledVersion = performToolInstallation(request, installationPath, resolvedVersion); | ||
| // If offline and could not download, actualInstalledVersion will be the old version, not resolvedVersion | ||
| // In that case, we need to recalculate the installation path for the actually installed version | ||
| if (!actualInstalledVersion.equals(resolvedVersion)) { | ||
| installationPath = getInstallationPath(edition, actualInstalledVersion); | ||
| } | ||
| return createToolInstallation(installationPath, actualInstalledVersion, true, processContext, additionalInstallation); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -212,13 +218,29 @@ public ToolInstallation installTool(ToolInstallRequest request) { | |
| * | ||
| * @param request the {@link ToolInstallRequest}. | ||
| * @param installationPath the target {@link Path} where the {@link #getName() tool} should be installed. | ||
| * @param resolvedVersion the {@link VersionIdentifier} that should be installed. | ||
| * @return the {@link VersionIdentifier} of the version that was actually installed. In offline scenarios where download fails, this may be different from | ||
| * {@code resolvedVersion} (returning the existing installed version instead). | ||
| */ | ||
| protected void performToolInstallation(ToolInstallRequest request, Path installationPath) { | ||
| protected VersionIdentifier performToolInstallation(ToolInstallRequest request, Path installationPath, VersionIdentifier resolvedVersion) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't it be easier to not change this signature and do the try-catch outside of BTW: using exceptions for control flow is not nice but I everything else would require way more refactoring - so I guess this should be fine here. |
||
|
|
||
| FileAccess fileAccess = this.context.getFileAccess(); | ||
| ToolEditionAndVersion requested = request.getRequested(); | ||
| VersionIdentifier resolvedVersion = requested.getResolvedVersion(); | ||
| Path downloadedToolFile = downloadTool(requested.getEdition().edition(), resolvedVersion); | ||
| Path downloadedToolFile; | ||
| try { | ||
| downloadedToolFile = downloadTool(requested.getEdition().edition(), resolvedVersion); | ||
| } catch (CliOfflineException e) { | ||
| // If we are offline and cannot download, check if we can continue with an existing installation | ||
| ToolEditionAndVersion installed = request.getInstalled(); | ||
| if ((installed != null) && (installed.getResolvedVersion() != null)) { | ||
| this.context.warning("Cannot download {} in version {} because we are offline. Continuing with already installed version {}.", | ||
| this.tool, resolvedVersion, installed.getResolvedVersion()); | ||
| // Return the existing installed version to indicate fallback | ||
| return installed.getResolvedVersion(); | ||
| } | ||
| // No existing installation available, re-throw the exception | ||
| throw e; | ||
| } | ||
| boolean extract = isExtract(); | ||
| if (!extract) { | ||
| this.context.trace("Extraction is disabled for '{}' hence just moving the downloaded file {}.", this.tool, downloadedToolFile); | ||
|
|
@@ -234,6 +256,7 @@ protected void performToolInstallation(ToolInstallRequest request, Path installa | |
| fileAccess.extract(downloadedToolFile, installationPath, this::postExtract, extract); | ||
| this.context.writeVersionFile(resolvedVersion, installationPath); | ||
| this.context.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath); | ||
| return resolvedVersion; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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
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.