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

feat: Added feature to perform in-place update of Drifty #562

Merged
merged 50 commits into from
Sep 7, 2024

Conversation

SaptarshiSarkar12
Copy link
Owner

@SaptarshiSarkar12 SaptarshiSarkar12 commented Jul 6, 2024

Fixes issue

Fixes #217

Changes proposed

  • Added a package to check for available update
  • Added in-place update methods for both CLI and GUI
  • Added a settings option to choose if the user wants to receive Early Access updates (Alpha, Beta, RC) along with Stable versions

Tested Working in/for

  • Drifty CLI / Windows
  • Drifty GUI (exe) / Windows
  • Drifty GUI (msi) / Windows (requires Administrative Privileges)
  • Drifty CLI / Linux
  • Drifty GUI / Linux
  • Drifty CLI / MacOS
  • Drifty GUI / MacOS (PKG installer is opened up for the user to install the latest version)

Note

For Windows, the .old executable remains after update completes. Once the new executable (starting from version 2.1.0) is run, it deletes that old file during initialisation.

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Screenshots

Drifty.GUI.Linux.updating.webm
Drifty.CLI.Linux.Updating.webm
Drifty.GUI.updating.with.admin.permission.webm
Drifty.GUI.fails.to.update.without.admin.permission.webm

Summary by CodeRabbit

  • New Features

    • Introduced a new inspection tool for managing auto-closeable resources to enhance code quality.
    • Added command-line flags for updating and early access options in the CLI application.
    • Implemented a new update management feature allowing users to check for updates directly from the GUI.
    • Included a checkbox in settings for opting into early access updates.
  • Enhancements

    • Improved error handling in various components, providing clearer feedback for users.
    • Enhanced logging functionality for better tracking of application behavior.
    • Streamlined the update process with better user interaction and feedback mechanisms.
    • Added a new constant for representing one day in milliseconds and improved the initialization of the update URL.
  • Bug Fixes

    • Resolved issues related to file permissions and update execution across different operating systems.
  • Documentation

    • Updated help outputs to reflect new command-line options and GUI features.

Copy link

vercel bot commented Jul 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drifty ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 7, 2024 8:07am

Copy link
Contributor

coderabbitai bot commented Jul 6, 2024

Walkthrough

Walkthrough

The changes introduce a comprehensive update feature for the Drifty application, enabling it to check for the latest version and facilitate automatic updates upon user confirmation. This includes enhancements in update management, error handling, and user interface adjustments to provide clear feedback during update checks.

Changes

File(s) Change Summary
.idea/inspectionProfiles/Project_Default.xml Added inspection tool for AutoCloseableResource to improve resource management checks.
CLI/src/main/java/cli/support/Constants.java Introduced new constants for update URL and time representation.
CLI/src/main/java/cli/updater/CLIUpdateExecutor.java Implemented the update execution logic for the CLI application.
Core/src/main/java/init/Environment.java Enhanced environment initialization to check for admin privileges and updates.
Core/src/main/java/updater/UpdateChecker.java Created a class to check for software updates against the latest version on GitHub.
GUI/src/main/java/main/Drifty_GUI.java Added a menu item for checking updates and modified initialization logic.
GUI/src/main/java/ui/UIController.java Implemented update dialog and download management in the UI.

Assessment against linked issues

Objective Addressed Explanation
Drifty should check if the user is running the latest version (217)
Drifty should update itself after user confirmation (217)

🐰 "Oh, hop along, the updates are here,
With checks for the latest, there's nothing to fear!
Click and confirm, let the magic unfold,
Drifty's now shiny, with features untold!
So bounce with delight, let the updates commence,
A world of new wonders, it all makes sense!" 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the App 💻 Issues/Pull Requests which update Drifty Application Code label Jul 6, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! You did it 🎉 Now, Relax 😉, Grab a drink ☕, and wait for the maintainers to check your contributions. Meanwhile, you can discuss on other issues and solve them 😀. Thank You 😃!

Meanwhile you can also discuss about the project in our Discord Server 😀

@SaptarshiSarkar12 SaptarshiSarkar12 added the feature ✨ New feature request or addition label Jul 6, 2024
Copy link
Contributor

❌ Linting errors found!

@SaptarshiSarkar12 Please fix the following errors:

Core/src/main/java/utils/Utility.java:120:1: Comment has incorrect indentation level 0, expected is 8, indentation should be the same level as line 121. [CommentsIndentation]

Generated from this workflow run (ID: 10438012809)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

Outside diff range, codebase verification and nitpick comments (4)
GUI/src/main/java/module-info.java (1)

10-10: jproc library is not utilized in the GUI module.

The search results indicate that the jproc library is not being used within the GUI module. The only reference to jproc is in the module-info.java file, and no specific classes or methods from jproc are found in the codebase. Consider removing the requires jproc; statement if the library is not needed.

  • module-info.java: Contains the requires jproc; statement without any usage in the codebase.
Analysis chain

Dependency addition approved but verify usage.

The addition of requires jproc; is correctly implemented. However, verify that jproc is utilized within the GUI module.

Run the following script to verify the usage of jproc within the GUI module:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `jproc` is utilized within the GUI module.

# Test: Search for usage of `jproc` library in the GUI module. Expect: At least one usage.
rg --type java "jproc" GUI/src/main/java

Length of output: 95


Script:

#!/bin/bash
# Description: Identify classes or methods provided by the `jproc` library.

# Assuming `jproc` is a known library, let's search for its usage by identifying common classes or methods.
# Since we don't have access to the library's documentation, we'll search for common usage patterns.

# Search for common `jproc` classes or methods in the codebase.
rg --type java "ProcessBuilder" GUI/src/main/java
rg --type java "Process" GUI/src/main/java

Length of output: 1797

CLI/src/main/java/cli/utils/MessageBroker.java (1)

34-36: Well-implemented new method for update warnings.

The msgUpdateWarning method is correctly implemented and aligns with the existing methods in MessageBroker. It uses the appropriate message type and category for update-related warnings.

Consider adding documentation to this method to explain its specific use case and parameters.

Core/src/main/java/utils/MessageBroker.java (1)

94-94: Enhanced message formatting based on category.

The modification in the sendMessage method to format messages based on their category (blue for INPUT and UPDATE) enhances clarity. However, consider caching the formatted message strings if performance becomes a concern, especially under heavy logging.

GUI/src/main/resources/META-INF/native-image/reflect-config.json (1)

Line range hint 1-1: Review of reflect-config.json Changes

The removal of the Solid_Color_Loader entry from the reflection configuration suggests a significant change in how shaders are managed within the application. This change should be carefully documented, especially if it impacts existing functionalities or the performance of shader loading. Ensure that any dependencies or functionalities that relied on the Solid_Color_Loader are either updated or replaced to maintain application stability and performance.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7dadc0b and a097918.

Files selected for processing (35)
  • .idea/inspectionProfiles/Project_Default.xml (1 hunks)
  • CLI/src/main/java/cli/support/Constants.java (1 hunks)
  • CLI/src/main/java/cli/updater/CLIUpdateExecutor.java (1 hunks)
  • CLI/src/main/java/cli/utils/MessageBroker.java (1 hunks)
  • CLI/src/main/java/cli/utils/Utility.java (4 hunks)
  • CLI/src/main/java/main/Drifty_CLI.java (10 hunks)
  • CLI/src/main/resources/META-INF/native-image/jni-config.json (1 hunks)
  • CLI/src/main/resources/META-INF/native-image/reflect-config.json (2 hunks)
  • CLI/src/main/resources/META-INF/native-image/resource-config.json (1 hunks)
  • Core/src/main/java/init/Environment.java (4 hunks)
  • Core/src/main/java/module-info.java (1 hunks)
  • Core/src/main/java/preferences/Clear.java (1 hunks)
  • Core/src/main/java/preferences/Get.java (1 hunks)
  • Core/src/main/java/preferences/Labels.java (1 hunks)
  • Core/src/main/java/preferences/Set.java (1 hunks)
  • Core/src/main/java/properties/MessageCategory.java (1 hunks)
  • Core/src/main/java/support/Constants.java (2 hunks)
  • Core/src/main/java/updater/UpdateChecker.java (1 hunks)
  • Core/src/main/java/updater/UpdateExecutor.java (1 hunks)
  • Core/src/main/java/utils/Logger.java (5 hunks)
  • Core/src/main/java/utils/MessageBroker.java (1 hunks)
  • Core/src/main/java/utils/Utility.java (29 hunks)
  • GUI/src/main/java/backend/FileDownloader.java (2 hunks)
  • GUI/src/main/java/gui/updater/GUIUpdateExecutor.java (1 hunks)
  • GUI/src/main/java/gui/utils/MessageBroker.java (2 hunks)
  • GUI/src/main/java/gui/utils/UIComponentBuilder.java (2 hunks)
  • GUI/src/main/java/main/Drifty_GUI.java (4 hunks)
  • GUI/src/main/java/module-info.java (1 hunks)
  • GUI/src/main/java/ui/ConfirmationDialog.java (5 hunks)
  • GUI/src/main/java/ui/GetFilename.java (2 hunks)
  • GUI/src/main/java/ui/Settings.java (6 hunks)
  • GUI/src/main/java/ui/Splash.java (1 hunks)
  • GUI/src/main/java/ui/UIController.java (4 hunks)
  • GUI/src/main/resources/META-INF/native-image/reflect-config.json (1 hunks)
  • GUI/src/main/resources/META-INF/native-image/resource-config.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • GUI/src/main/resources/META-INF/native-image/resource-config.json
Additional comments not posted (64)
Core/src/main/java/properties/MessageCategory.java (1)

4-4: Enum addition approved.

The addition of UPDATE to the MessageCategory enum is correctly implemented and aligns with the PR objectives to enhance message handling for updates.

Core/src/main/java/module-info.java (1)

13-13: Export statement approved but verify package contents.

The addition of exports updater; is correctly implemented. However, verify that the updater package contains public types that should be accessible to other modules.

Run the following script to verify the contents of the updater package:

Verification successful

Verification Successful: Public Type Found in updater Package

The updater package contains the public class UpdateChecker, confirming that the package has public types suitable for export. The export statement is correctly implemented.

  • Core/src/main/java/updater/UpdateChecker.java: Contains the public class UpdateChecker.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `updater` package contains public types.

# Test: Search for public classes or interfaces in the `updater` package. Expect: At least one public type.
rg --type java "public (class|interface)" Core/src/main/java/updater

Length of output: 145

Core/src/main/java/preferences/Labels.java (5)

14-14: Approved: New constant for Drifty version name.

The addition of NEW_DRIFTY_VERSION_NAME is consistent with the PR objectives and follows the established naming conventions.


15-15: Approved: New constant for latest Drifty version tag.

The addition of LATEST_DRIFTY_VERSION_TAG is consistent with the PR objectives and follows the established naming conventions.


16-16: Approved: New constant for last Drifty update time.

The addition of LAST_DRIFTY_UPDATE_TIME is consistent with the PR objectives and follows the established naming conventions.


17-17: Approved: New constant for early access option.

The addition of EARLY_ACCESS is consistent with the PR objectives and follows the established naming conventions.


18-18: Approved: New constant for update availability status.

The addition of DRIFTY_UPDATE_AVAILABLE is consistent with the PR objectives and follows the established naming conventions.

CLI/src/main/resources/META-INF/native-image/jni-config.json (1)

10-13: Approved: New JNI configuration for Drifty_CLI.

The addition of the main.Drifty_CLI entry in the JNI configuration file is correctly implemented and aligns with the PR objectives to enhance JNI support for the CLI.

.idea/inspectionProfiles/Project_Default.xml (1)

4-6: Approved: New inspection tool configuration for AutoCloseableResource.

The addition of the AutoCloseableResource inspection tool in the project's inspection profiles is well-implemented and enhances the project's ability to monitor and manage resource usage effectively.

CLI/src/main/resources/META-INF/native-image/resource-config.json (1)

10-10: Correct addition to resource configuration.

The new entry for java.nio.channels.spi.SelectorProvider is correctly added and follows the established JSON structure. This change is likely to enhance the application's non-blocking I/O capabilities.

Core/src/main/java/preferences/Clear.java (5)

42-44: Approved: Method to remove early access preference.

The method correctly removes the EARLY_ACCESS preference key, aligning with the PR's objectives to manage user settings effectively.


46-48: Approved: Method to remove new Drifty version name preference.

This method effectively clears the NEW_DRIFTY_VERSION_NAME preference, which is crucial for managing version control settings.


50-52: Approved: Method to remove last Drifty update time preference.

The method correctly removes the LAST_DRIFTY_UPDATE_TIME preference, ensuring that outdated update times do not persist in the system.


54-56: Approved: Method to remove latest Drifty version tag preference.

This method effectively clears the LATEST_DRIFTY_VERSION_TAG preference, which is essential for version tracking and update prompts.


58-60: Approved: Method to remove Drifty update available preference.

The method correctly removes the DRIFTY_UPDATE_AVAILABLE preference, which is crucial for managing update notifications.

GUI/src/main/java/gui/utils/MessageBroker.java (1)

39-43: Approved: Enhanced error handling for update failures.

The addition of the UPDATE case in the sendMessage method is well-implemented, using a modal dialog to ensure user interaction and feedback during update failures. This enhancement aligns with the PR's objectives to improve user experience and error handling.

GUI/src/main/java/ui/Splash.java (1)

50-50: Approved: Adjusted timing for splash screen closure.

The modification in the handleStateChangeNotification method to check for StateChangeNotification.Type.BEFORE_START instead of BEFORE_LOAD is a thoughtful change. It likely improves the user experience by aligning the splash screen's closure with the application's readiness, especially considering different update scenarios.

GUI/src/main/java/gui/utils/UIComponentBuilder.java (2)

10-10: Approved import addition.

The import of Border is necessary for the new border setting in the buildHyperlink method and is correctly placed.


69-69: Approved method change with a suggestion to verify UI consistency.

The addition of link.setBorder(Border.EMPTY); is intended to enhance the visual presentation of hyperlinks. It's important to verify that this change maintains visual consistency across different parts of the application.

Run the following script to verify the visual consistency across the application:

Verification successful

Visual consistency of hyperlinks verified.

The change to set the border of hyperlinks to Border.EMPTY is consistently applied across the application, as there are no other instances of Hyperlink creation found in the codebase. This ensures a uniform visual presentation of hyperlinks.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the visual consistency of hyperlinks across the application.

# Test: Search for other instances of `Hyperlink` usage. Expect: Consistent border settings or intentional differences.
rg --type java -A 5 $'new Hyperlink'

Length of output: 583

Core/src/main/java/support/Constants.java (1)

27-27: Constant Addition Approved: ONE_DAY

The constant ONE_DAY is correctly defined as 86400000 milliseconds, representing one day. This is a useful addition for time-related calculations.

CLI/src/main/java/cli/support/Constants.java (4)

16-16: Constant Addition Approved: UPDATE_FLAG

The constant UPDATE_FLAG is correctly defined as --update. This flag is consistent with the existing pattern of CLI flags and enhances the command set available to users.


17-17: Constant Addition Approved: EARLY_ACCESS_FLAG

The constant EARLY_ACCESS_FLAG is correctly defined as --early-access. This flag provides users with the option to opt-in for Early Access updates, enhancing the flexibility of the CLI.


23-23: Constant Addition Approved: UPDATE_FLAG_SHORT

The constant UPDATE_FLAG_SHORT is correctly defined as -u. This short form is consistent with the existing pattern of CLI flags and provides a convenient alternative for users.


24-24: Constant Addition Approved: EARLY_ACCESS_FLAG_SHORT

The constant EARLY_ACCESS_FLAG_SHORT is correctly defined as -ea. This short form provides a convenient alternative for users opting for Early Access updates.

Core/src/main/java/updater/UpdateExecutor.java (1)

60-73: Method Approval: replaceCurrentExecutable

The method replaceCurrentExecutable is well-implemented with robust error handling and fallback mechanisms. The use of Files.move followed by Files.copy as a fallback ensures that the update process is resilient to potential file operation failures.

Core/src/main/java/utils/MessageBroker.java (2)

79-81: Well-implemented method for categorized error messages.

The msgError method correctly delegates the message handling to sendMessage, allowing for categorized error messages. This addition enhances the flexibility and usability of the messaging system.


83-89: Specialized methods for update-related messages are correctly implemented.

The methods msgUpdateError and msgUpdateInfo are well-designed, using the sendMessage method effectively to handle update-related messages. This approach enhances clarity and maintainability.

Core/src/main/java/preferences/Get.java (5)

105-107: Proper implementation of the earlyAccess method.

The method earlyAccess correctly retrieves the early access status from the preferences. Using false as the default value is a safe and sensible choice.


109-111: Well-implemented method for retrieving the new Drifty version name.

The method newDriftyVersionName correctly retrieves the new version name from the preferences, with an empty string as a sensible default.


113-115: Correct implementation of the lastDriftyUpdateTime method.

The method lastDriftyUpdateTime appropriately retrieves the last update time from the preferences, with 1000L as a default value, which seems arbitrary but may be intentional based on the application's context.


117-119: Properly implemented method for retrieving the latest Drifty version tag.

The method latestDriftyVersionTag correctly retrieves the latest version tag from the preferences, with an empty string as a sensible default.


121-123: Correct implementation of the driftyUpdateAvailable method.

The method driftyUpdateAvailable appropriately checks if an update is available from the preferences, using false as the default value, which is a safe and sensible choice.

Core/src/main/java/preferences/Set.java (5)

103-106: Well-implemented method for setting the early access flag.

The method earlyAccess correctly sets the early access flag in the preferences, including a call to clear any previous settings, which ensures that the new setting is applied cleanly.


108-111: Properly implemented method for storing the new Drifty version name.

The method newDriftyVersionName correctly stores the new version name in the preferences, including a call to clear any previous settings, which ensures that the new setting is applied cleanly.


113-116: Correct implementation of the lastDriftyUpdateTime method.

The method lastDriftyUpdateTime appropriately records the last update time in the preferences, including a call to clear any previous settings, which ensures that the new setting is applied cleanly.


118-121: Properly implemented method for storing the latest Drifty version tag.

The method latestDriftyVersionTag correctly stores the latest version tag in the preferences, including a call to clear any previous settings, which ensures that the new setting is applied cleanly.


123-126: Correct implementation of the driftyUpdateAvailable method.

The method driftyUpdateAvailable appropriately indicates whether an update is available in the preferences, including a call to clear any previous settings, which ensures that the new setting is applied cleanly.

CLI/src/main/java/cli/utils/Utility.java (2)

58-58: Consistency Improved in Messaging

The replacement of static references with msgBroker in the yesNoValidation method is a good practice for maintaining consistency in how messages are handled across the application.

Also applies to: 69-69


121-121: Consistent Logging Practice

Using msgBroker to log the successful initialization of the YAML parser in the getYamlParser method is a good practice for maintaining consistency in logging across the application.

Core/src/main/java/init/Environment.java (1)

137-139: Simple and Effective Accessor Method

The isAdministrator method provides a straightforward and effective way to access the administrative status externally. This is a necessary addition for other parts of the application to check the administrative rights.

Core/src/main/java/updater/UpdateChecker.java (5)

21-35: Method isUpdateAvailable is well-implemented.

This method correctly handles the logic to determine if an update is available based on user settings and version comparison. It also appropriately logs information and updates the application settings.


37-48: Method getLatestStableVersion is correctly implemented.

The method effectively fetches the latest stable version from GitHub and handles potential URISyntaxException appropriately by logging the error and returning a safe fallback value.


50-61: Method getLatestPreReleaseVersion follows best practices.

Like getLatestStableVersion, this method correctly fetches the latest pre-release version from GitHub and handles potential URISyntaxException appropriately.


87-137: Method compareVersions is robust and well-implemented.

This method effectively handles the comparison of version strings, including different scenarios like stable vs pre-release versions. It uses custom parsing with appropriate error handling, making it robust against potential parsing errors.


139-148: Method getTagParts correctly parses version tags.

The method accurately splits version tags into their constituent parts, handling both standard and pre-release formats effectively.

GUI/src/main/java/main/Drifty_GUI.java (3)

36-36: Approved: Setting GUI mode in main method.

Setting the GUI mode at the start of the application ensures that the application runs in the correct mode from the beginning.


47-48: Approved: Enhancements to initialization process in init method.

The addition of Environment.initializeEnvironment() and preloader notification in the init method enhances the application's startup process by ensuring that the environment is properly set up and the user is informed of the state change.


171-171: Approved: Addition of confirmation dialog in getEditMenu.

The inclusion of a confirmation dialog before clearing download history enhances user interaction by ensuring that the user's intent is confirmed before performing this action.

GUI/src/main/java/backend/FileDownloader.java (1)

414-416: Improved Error Handling in Time Parsing:

The changes in the setProperties method enhance error handling by providing specific error messages when parsing hours, minutes, and seconds fails. This improvement aligns with the PR's goal to enhance user feedback and robustness of the application.

Core/src/main/java/utils/Utility.java (2)

42-45: Refactor of MessageBroker Initialization:

The introduction of the initializeUtility method for lazy initialization of MessageBroker enhances the flexibility and maintainability of the code. This change allows for better handling of scenarios where the Environment's MessageBroker might not be set during class loading.


846-850: Enhanced Error Handling in parseStringToInt:

The modification of the parseStringToInt method to include error messages and a message category significantly improves the error handling capabilities of the utility class. This change allows for more context-specific error messages, enhancing the robustness and user feedback of the application.

GUI/src/main/java/ui/UIController.java (2)

108-117: Enhanced Update Dialog Interaction:

The changes to the showUpdateDialog method improve user interaction by providing tailored update prompts based on the user's operating system and permissions. This enhancement ensures that users receive appropriate guidance on how to proceed with updates, improving the overall user experience.


120-164: Improved Update Download and Installation Process:

The downloadUpdate method has been enhanced to better manage the update process, including handling temporary directories, prioritizing the download queue, and executing the update. These changes improve the reliability and user experience of the update process, ensuring that updates are handled smoothly and efficiently.

CLI/src/main/java/main/Drifty_CLI.java (2)

353-356: Method to check if Drifty update was checked

This method provides a simple check to see if updates have been checked within a day. It's a good use of system time comparison to manage update frequency.


596-611: Updated help method to reflect new command-line options

The updated help method now includes the new command-line options for updates and early access. This is a crucial update for user documentation and helps maintain the usability of the application.

GUI/src/main/java/ui/GetFilename.java (1)

166-166: Enhanced error handling in getFileCount method.

The addition of specific error messages and categorization in the Utility.parseStringToInt method call is a good practice for better error management. Ensure that the Utility class and the MessageCategory enum are updated accordingly to handle these new parameters.

Run the following script to verify the implementation of the new parameters in the Utility class:

Verification successful

Verification successful: Enhanced error handling in Utility.parseStringToInt.

The Utility.parseStringToInt method correctly implements the new parameters for error handling, using a descriptive error message and a MessageCategory to categorize errors. This implementation enhances the robustness of error management across the codebase.

  • The method logs errors with the provided message and category, ensuring clear and categorized error reporting.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the new parameters in the `Utility.parseStringToInt` method.

# Test: Search for the method implementation. Expect: Method should handle the new parameters.
rg --type java -A 5 $'parseStringToInt'

Length of output: 5234

CLI/src/main/resources/META-INF/native-image/reflect-config.json (3)

48-49: Approved addition of HmacCore$HmacSHA256 for reflection.

The inclusion of HmacCore$HmacSHA256 in the reflection configuration supports cryptographic operations in the native image, which is crucial for secure data handling.


118-119: Approved addition of AtomicBoolean for reflection.

The inclusion of AtomicBoolean and its field value ensures that thread-safe operations are correctly handled in the native image, preserving the integrity of concurrent operations.


122-123: Approved addition of AtomicReference for reflection.

The inclusion of AtomicReference and its field value is essential for ensuring that updates to references in concurrent environments are handled correctly in the native image.

GUI/src/main/java/ui/Settings.java (4)

79-79: Approved layout configuration updates.

The updates to the layout configuration to accommodate the new earlyAccessCheckbox and lblEarlyAccess are appropriate. Ensure that these changes do not adversely affect the overall layout and that the components grow correctly with the layout.

Run the following script to verify the layout configuration:

Verification successful

Layout configuration updates verified.

The layout configuration updates to include lblEarlyAccess and earlyAccessCheckbox in the setHGrowsAlways method are correct. The method ensures that these components will grow horizontally as intended, maintaining the overall layout integrity. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the layout configuration for the new components.

# Test: Search for the layout configuration. Expect: Correct growth settings for the new components.
rg --type java -A 5 $'setHGrowsAlways'

Length of output: 933


149-154: Approved addition of earlyAccessCheckbox.

The implementation of the earlyAccessCheckbox allows users to opt into early access updates, enhancing user engagement. Ensure that it is correctly integrated with the application settings and that its state changes are handled appropriately.

Run the following script to verify the integration with the application settings:

Verification successful

Verification successful for earlyAccessCheckbox integration.

The earlyAccessCheckbox is correctly integrated with the application settings. Its initial state is set using AppSettings.GET.earlyAccess(), and changes are saved using AppSettings.SET.earlyAccess(newValue). This ensures proper synchronization between the UI and the application settings.

  • earlyAccessCheckbox initialization and state handling are correctly implemented in Settings.java.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `earlyAccessCheckbox` with the application settings.

# Test: Search for the settings integration. Expect: Proper handling of state changes.
rg --type java -A 5 $'earlyAccessCheckbox'

Length of output: 2377


Line range hint 31-160: Approved integration of early access updates feature.

The integration of the early access updates feature into the Settings class is well-executed, enhancing the functionality of the settings interface. Verify that the feature works as expected across different user scenarios and that it is consistent with other settings.

Run the following script to verify the overall integration:

Verification successful

Successful integration of early access updates feature.

The early access updates feature is consistently integrated into the Settings class. The earlyAccessCheckbox is properly initialized, configured, and added to the UI layout, with a listener set up to update the application settings. No issues were found in the integration.

  • The earlyAccessCheckbox is declared, initialized, and configured correctly.
  • It is added to the UI layout and its properties are managed appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the overall integration of the early access updates feature.

# Test: Search for the integration across different methods. Expect: Consistent implementation and handling.
rg --type java -A 10 $'earlyAccessCheckbox'

Length of output: 4141


111-111: Approved addition of lblEarlyAccess.

The lblEarlyAccess label is correctly added to the layout, enhancing the clarity of the settings related to early access updates. Verify that it is visually aligned with other components for a consistent user interface.

Run the following script to verify the visual alignment:

Verification successful

Visual alignment of lblEarlyAccess is consistent.

The lblEarlyAccess label is correctly aligned and styled in the layout, matching the alignment and styling of other components such as lblTheme and lblDefaultDownloadDir. This ensures a consistent and visually appealing user interface. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the visual alignment of `lblEarlyAccess` with other components.

# Test: Search for the layout configuration. Expect: Consistent alignment with other components.
rg --type java -A 5 $'lblEarlyAccess'

Length of output: 3150

GUI/src/main/resources/META-INF/native-image/reflect-config.json (1)

Line range hint 1-1: JSON Structure and Formatting Approval

The JSON structure is consistent and correctly formatted. All entries are correctly placed, and the file adheres to the expected syntax for a reflection configuration. This ensures that the native image generation process can correctly interpret the specified classes and methods.

CLI/src/main/java/cli/updater/CLIUpdateExecutor.java Outdated Show resolved Hide resolved
GUI/src/main/java/gui/updater/GUIUpdateExecutor.java Outdated Show resolved Hide resolved
Core/src/main/java/utils/Logger.java Show resolved Hide resolved
Core/src/main/java/utils/Logger.java Show resolved Hide resolved
Core/src/main/java/support/Constants.java Show resolved Hide resolved
Core/src/main/java/updater/UpdateChecker.java Show resolved Hide resolved
GUI/src/main/java/main/Drifty_GUI.java Outdated Show resolved Hide resolved
CLI/src/main/java/main/Drifty_CLI.java Show resolved Hide resolved
CLI/src/main/java/main/Drifty_CLI.java Outdated Show resolved Hide resolved
CLI/src/main/java/main/Drifty_CLI.java Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a097918 and fb404cb.

Files selected for processing (12)
  • CLI/src/main/java/cli/updater/CLIUpdateExecutor.java (1 hunks)
  • CLI/src/main/java/cli/utils/Utility.java (4 hunks)
  • CLI/src/main/java/main/Drifty_CLI.java (10 hunks)
  • Core/src/main/java/init/Environment.java (5 hunks)
  • Core/src/main/java/updater/UpdateChecker.java (1 hunks)
  • Core/src/main/java/updater/UpdateExecutor.java (1 hunks)
  • Core/src/main/java/utils/Utility.java (29 hunks)
  • GUI/src/main/java/gui/updater/GUIUpdateExecutor.java (1 hunks)
  • GUI/src/main/java/main/Drifty_GUI.java (4 hunks)
  • GUI/src/main/java/ui/ConfirmationDialog.java (7 hunks)
  • GUI/src/main/java/ui/Theme.java (1 hunks)
  • GUI/src/main/java/ui/UIController.java (4 hunks)
Files skipped from review as they are similar to previous changes (10)
  • CLI/src/main/java/cli/updater/CLIUpdateExecutor.java
  • CLI/src/main/java/cli/utils/Utility.java
  • Core/src/main/java/init/Environment.java
  • Core/src/main/java/updater/UpdateChecker.java
  • Core/src/main/java/updater/UpdateExecutor.java
  • Core/src/main/java/utils/Utility.java
  • GUI/src/main/java/gui/updater/GUIUpdateExecutor.java
  • GUI/src/main/java/main/Drifty_GUI.java
  • GUI/src/main/java/ui/ConfirmationDialog.java
  • GUI/src/main/java/ui/UIController.java
Additional context used
Learnings (1)
CLI/src/main/java/main/Drifty_CLI.java (1)
Learnt from: SaptarshiSarkar12
PR: SaptarshiSarkar12/Drifty#398
File: CLI/src/main/java/main/Drifty_CLI.java:437-440
Timestamp: 2023-12-22T11:43:49.346Z
Learning: User SaptarshiSarkar12 is aware of the potential null issue in `getSpotifyDownloadLink` but prefers not to introduce null checks to avoid complexity.
Additional comments not posted (2)
GUI/src/main/java/ui/Theme.java (1)

106-106: Approved: Update to button styling method.

The addition of changeButtonStyle for the BtnOk button aligns with the existing functionality of the updateButtonStyles method. Ensure that the ConfirmationDialog.getBtnOk() method is implemented correctly and returns the expected button instance.

Run the following script to verify the implementation of ConfirmationDialog.getBtnOk():

Verification successful

Verified: ConfirmationDialog.getBtnOk() Implementation

The getBtnOk() method in the ConfirmationDialog class is correctly implemented, returning the btnOk button instance as expected. This aligns with the intended functionality of updating button styles in the updateButtonStyles method.

  • ConfirmationDialog.getBtnOk() returns a button instance, confirming its correct implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `ConfirmationDialog.getBtnOk()`.

# Test: Search for the method implementation. Expect: Method should return a Button instance.
rg --type java -A 5 $'getBtnOk'

Length of output: 704

CLI/src/main/java/main/Drifty_CLI.java (1)

364-367: Approved: Method to check update frequency.

The isDriftyUpdateChecked method is correctly implemented to ensure that updates are checked no more than once a day. This is a good practice to avoid excessive network calls.

CLI/src/main/java/main/Drifty_CLI.java Outdated Show resolved Hide resolved
CLI/src/main/java/main/Drifty_CLI.java Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb404cb and e13a1ab.

Files selected for processing (5)
  • CLI/src/main/java/main/Drifty_CLI.java (10 hunks)
  • Core/src/main/java/support/Constants.java (2 hunks)
  • Core/src/main/java/updater/UpdateChecker.java (1 hunks)
  • Core/src/main/java/utils/Utility.java (29 hunks)
  • GUI/src/main/java/main/Drifty_GUI.java (3 hunks)
Files skipped from review as they are similar to previous changes (5)
  • CLI/src/main/java/main/Drifty_CLI.java
  • Core/src/main/java/support/Constants.java
  • Core/src/main/java/updater/UpdateChecker.java
  • Core/src/main/java/utils/Utility.java
  • GUI/src/main/java/main/Drifty_GUI.java

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e13a1ab and 3f5e869.

Files selected for processing (1)
  • Core/src/main/java/support/Constants.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Core/src/main/java/support/Constants.java

Copy link
Owner Author

@SaptarshiSarkar12 SaptarshiSarkar12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@SaptarshiSarkar12 SaptarshiSarkar12 merged commit e9c7e0e into master Sep 7, 2024
68 checks passed
@SaptarshiSarkar12 SaptarshiSarkar12 deleted the 217-drifty-update-feature branch September 7, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App 💻 Issues/Pull Requests which update Drifty Application Code feature ✨ New feature request or addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a feature to update Drifty
1 participant