Skip to content

Create a new folder by default when making a portable copy, warn for non-empty directories#16686

Merged
seanbudd merged 10 commits into
masterfrom
newFolderPortable
Jun 17, 2024
Merged

Create a new folder by default when making a portable copy, warn for non-empty directories#16686
seanbudd merged 10 commits into
masterfrom
newFolderPortable

Conversation

@seanbudd

@seanbudd seanbudd commented Jun 13, 2024

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #16443

Summary of the issue:

When creating a portable copy, NVDA overwrites the contents of the folder. This may delete files like dlls.
This caused #16514 to be reported, as this can be quite destructive and unexpected.

Typical behaviour for writing to a directory like this involves creating a new folder to write the contents to.
However, portable copies can also be upgraded, so it is important to be able to support writing to existing portable copy directories.

Description of user facing changes

When creating a portable copy, a new checkbox has been added to create a new folder for the portable copy, which is checked by default.
If this box is unchecked, a warning dialog will appear if the directory is non-empty.
The directory contains nvda.exe we assume its a portable copy directory, and confirm the user wishes to upgrade the portable copy.
The directory is otherwise non-empty, a general warning dialog is opened warning the user that the contents of the folder will be overwritten.

Description of development approach

Added GUI elements to the create portable copy dialog

Testing strategy:

Manual testing

  • Tested a new folder is created when the checkbox is ticked
  • Tested a new folder named NVDA_1, NVDA_2, etc is created if the proposed new folder "NVDA" exists
  • Tested a new folder is not created when the checkbox is not ticked
  • Tested writing to an existing portable copy creates a warning before writing to disk
  • Tested writing to a non-empty directory creates a warning before writing to disk
  • Tested with --create-portable-silent: no warning should appear
  • Tested from cli with --create-portable: warnings should appear for non-empty, and upgrades

Known issues with pull request:

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Added a checkbox option to create a new folder for portable copies in the installation dialog.
    • Introduced warnings for non-empty directories when creating portable copies.
    • Updated command line options with detailed descriptions and requirements for creating portable copies.
  • Documentation

    • Enhanced user documentation with notes on new folder creation and warnings for non-empty directories during portable copy creation.
    • Updated help messages for --create-portable and --create-portable-silent command line options.

@seanbudd seanbudd requested a review from a team as a code owner June 13, 2024 06:04
@seanbudd seanbudd requested a review from michaelDCurran June 13, 2024 06:04
@coderabbitai

coderabbitai Bot commented Jun 13, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent updates primarily enhance the creation of portable NVDA copies. Key improvements include adding a warning for non-empty directories, the option to create a new folder for the portable installation, and better command-line options for silent installation. These enhancements aim to prevent accidental file scatter and improve user flexibility during the installation process.

Changes

File Path Change Summary
source/core.py Updated the doCreatePortable function to include a new parameter warnForNonEmptyDirectory to handle warnings for non-empty directories.
source/gui/installerGui.py Added new folder creation checkbox, validation functions for non-empty directories, and modifications to doCreatePortable function to support these changes.
source/nvda.pyw Enhanced descriptions and handling of --create-portable and --create-portable-silent command-line options.
user_docs/en/changes.md Documented the change providing accessibility reporting improvements and warning features for non-empty directories during portable creation.
user_docs/en/userGuide.md Added notes about the suppression of warnings when writing to non-empty directories for the --create-portable-silent command line option.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GUI
    participant Core
    participant Filesystem

    User->>GUI: Select 'Create Portable Copy' option
    GUI-->>User: Prompt user to select directory

    User->>GUI: Select directory
    GUI-->>User: Display 'Create new folder' checkbox

    User->>GUI: Check 'Create new folder'
    GUI->>Core: Call `doCreatePortable` with new folder option
    Core->>Filesystem: Check directory status

    alt Directory Not Empty
        Core->>GUI: Prompt warning for non-empty directory
        GUI-->>User: Display warning for non-empty directory
        User->>GUI: Confirm
    end

    Core->>Filesystem: Create portable copy in new folder

    GUI-->>User: Notify completion
Loading

Assessment against linked issues

Objective Addressed Explanation
Automatically create a new folder for portable copy creation (#16443)
Provide a checkbox option for creating a subdirectory during portable installation (#16443)
Warn users if the directory chosen for portable creation is not empty (#16443)
Improved command-line options for silent portable creation processes (#16443)

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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py
@seanbudd

Copy link
Copy Markdown
Member Author

@coderabbitai the checkbox for copying current user configuration during portable copy creation is not new

@coderabbitai

coderabbitai Bot commented Jun 13, 2024

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@seanbudd, thank you for pointing this out. The history check confirms that the copyUserConfigCheckbox has indeed been present before this PR. I apologize for the oversight in the AI-generated summary. I will correct this information for future references.

If there's anything else you need, please let me know!

Analysis chain

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search the history of `installerGui.py` for the introduction or changes related to `copyUserConfigCheckbox`
git log -S'copyUserConfigCheckbox' --source --all -p src/installerGui.py

Length of output: 272



Script:

#!/bin/bash
# Find the correct path for `installerGui.py`
fd installerGui.py

# Assuming the correct path is found, the following command should be used:
# git log -S'copyUserConfigCheckbox' --source --all -p -- <correct_path>

Length of output: 47



Script:

#!/bin/bash
# Search the history of `installerGui.py` for the introduction or changes related to `copyUserConfigCheckbox`
git log -S'copyUserConfigCheckbox' --source --all -p -- source/gui/installerGui.py

Length of output: 22527

@seanbudd seanbudd marked this pull request as draft June 13, 2024 06:17
@seanbudd seanbudd marked this pull request as ready for review June 13, 2024 06:27
@seanbudd

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Comment thread source/gui/installerGui.py
Comment thread source/gui/installerGui.py
Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py Outdated
@seanbudd seanbudd marked this pull request as draft June 13, 2024 06:43
@wmhn1872265132

Copy link
Copy Markdown
Contributor

I tested this PR and the GUI part is fine, however #16514 can still be reproduced through the command line --create-portable-silent --portable-path=""
At the same time, there is still the issue of inconsistent GUI and command line experience.

@seanbudd

Copy link
Copy Markdown
Member Author

@wmhn1872265132 I'd argue that --create-portable-silent should have no warnings, however this needs to be documented. warnings should definitely happen for the --create-portable case

@seanbudd seanbudd marked this pull request as ready for review June 14, 2024 05:37
@seanbudd seanbudd requested a review from a team as a code owner June 14, 2024 05:37
@seanbudd seanbudd requested a review from Qchristensen June 14, 2024 05:37
Comment thread source/gui/installerGui.py Outdated
@seanbudd

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Comment thread user_docs/en/userGuide.md Outdated
Comment thread source/nvda.pyw
Comment thread source/gui/installerGui.py
seanbudd and others added 2 commits June 14, 2024 15:55
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py Outdated
Comment thread source/gui/installerGui.py Outdated
Comment thread user_docs/en/userGuide.md Outdated
@seanbudd

Copy link
Copy Markdown
Member Author

@gerald-hartig - I've addressed those comments

Comment thread user_docs/en/userGuide.md
### Create portable copy {#CreatePortableCopy}

This will open a dialog which allows you to create a portable copy of NVDA out of the installed version.
Either way, when running a portable copy of NVDA, in the extra tool sub menu the menu item will be called "install NVDA on this PC" instead of "create portable copy).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think this is true, you can create a portable copy from a portable copy

@Qchristensen Qchristensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good work, this will help avoid confusion.

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 76aca61962

@seanbudd seanbudd merged commit f686900 into master Jun 17, 2024
@seanbudd seanbudd deleted the newFolderPortable branch June 17, 2024 05:58
seanbudd added a commit that referenced this pull request Jun 17, 2024
@cary-rowen

Copy link
Copy Markdown
Contributor

cc @gerald-hartig @seanbudd
I think #16514 is still not properly addressed.
Recursively deleting a user's files is inherently dangerous and unexpected behavior.

@seanbudd

Copy link
Copy Markdown
Member Author

@cary-rowen - can you explain how it is unexpected with it being clearly flagged now with a warning?
overwriting the contents of the folder is a required action, we can in theory do more to minimize the damage, but it is inherently unavoidable. I also don't think it is entirely unexpected for an action like this to delete or overwrite files, you are essentially declaring the directory for NVDA portable use only, however a warning is clearly needed.

@cary-rowen

Copy link
Copy Markdown
Contributor

We cannot assume that all users of use this parameter are fully aware of it just because a special case is documented.
Although we document it, I think the reason why accidents are called accidents is because they are unforeseen and lead to completely unexpected results.

@cary-rowen

Copy link
Copy Markdown
Contributor

The key here is that NVDA will delete the user's files, even if they have absolutely nothing to do with NVDA.
If you want to continue the discussion, I suggest reopening #16514 Thanks.

@seanbudd

Copy link
Copy Markdown
Member Author

@cary-rowen - are you talking particularly about the install-portable-silent case? I think it would be unusual if this creates a warning as you are specifying silent in this case. Otherwise, accidents are hard to happen, as a confirmation dialog is required before overwriting files, and it is more than documenting the case.

seanbudd added a commit that referenced this pull request Jul 15, 2024
Fixup of #16686
Fixes #16847

Summary of the issue:
When updating a portable copy either from the auto-update check UX, or through the portable copy CLI, a warning is shown to confirm if a user wants to update and overwrite the portable copy.
This is not ideal UX, as the update check UX should assume the user wants to update, same with the portable copy CLI.

Additionally, some translator strings in #16686 were not formatted correctly

Description of user facing changes
Warnings are no longer shown when updating a portable copy via the auto-update UX or via CLI.
Warnings are still shown when overwriting any other directory via CLI.

Messages in warning dialogs are now translatable correctly

Description of development approach
Fix format of translation strings

check if an update is being performed when creating a portable copy via CLI, do not warn in that case.
The portable copy auto-update UX uses the CLI to perform the update.
@tmthywynn8

Copy link
Copy Markdown

Question, and I'm not sure if it's intended behavior, but I notice that if I manually clear out a portable NVDA copy of everything but its userConfig directory, NVDA says that "[p]roceeding will delete and replace existing files in the directory." Once I do proceed though, the userConfig remains in existence. From reading the dialog and the issue summary, it sounds like existing files would both be deleted and replaced.

While I am glad that my userConfig data wasn't deleted, should that have been the case? Or should the prompt be shortened to just: "Proceeding will replace existing files in the directory"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature to automatically Create a new folder and put all files there when creating a portable copy

7 participants