Skip to content

Added a condition that checks if a addon directory is empty when loading it initially.#9372

Merged
feerrenrut merged 8 commits into
nvaccess:masterfrom
awalvie:i7686
Mar 27, 2019
Merged

Added a condition that checks if a addon directory is empty when loading it initially.#9372
feerrenrut merged 8 commits into
nvaccess:masterfrom
awalvie:i7686

Conversation

@awalvie

@awalvie awalvie commented Mar 13, 2019

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #7686

Summary of the issue:

Currently NVDA's addonHandler only checks whether an addon directory exists or not, if it does, then it tries to load the addon from the directory. The issue arises when files are manually deleted from a Addon folder except from the folder itself. As the addon still has a directory it's empty and hence does not contain the necessary files, which throws an error that stop NVDA from starting.

Original Issue

Description of how this pull request fixes the issue:

As suggested in the issue conversation I am just checking if the addon directory has any files inside it.

Testing performed:

  1. Installed the BrowserNav Plugin
  2. Restarted NVDA with addons Disabled and removed all files in BrowserNav's Folder
  3. Restarted NVDA with addons Enabled

(Exptected)

NVDA Fails to start as the addon directory has no files.

(After Fix)

NVDA Does indeed restart with a log.error() specifying that the addon at the following location could not be loaded.

Known issues with pull request:

It fixes the issue but dose not inform the user that the addon has been deleted

Section: Bug fixes

@awalvie awalvie changed the title Fix for #7686 Added a condition that checks if a addon directory is empty when loading it initially. Mar 13, 2019
@awalvie

awalvie commented Mar 13, 2019

Copy link
Copy Markdown
Contributor Author

I don't understand why the test build fails. Can someone help me out with this and suggest better changes ?

@LeonarddeR

LeonarddeR commented Mar 13, 2019 via email

Copy link
Copy Markdown
Collaborator

@josephsl

josephsl commented Mar 13, 2019 via email

Copy link
Copy Markdown
Contributor

@awalvie

awalvie commented Mar 13, 2019

Copy link
Copy Markdown
Contributor Author

Alright, thanks for the quick replies guys, this is my first pull request so I thought I might've made a mistake.

@feerrenrut

Copy link
Copy Markdown
Contributor

Because this issue is indicative of a broader error state, we should not merely hide this situation. I would recommend adding a log message at the error level to warn the user / developer that this has occurred. NVDA should then be able to continue, excluding this addon.

@awalvie

awalvie commented Mar 20, 2019

Copy link
Copy Markdown
Contributor Author

Got it i'll try adding that in. Can someone tell me how to access the access to the log file works in NVDA. Can I just use a with open block to write the error to it ?

@LeonarddeR

This comment has been minimized.

@josephsl

This comment has been minimized.

@awalvie

This comment has been minimized.

@josephsl

This comment has been minimized.

@feerrenrut

Copy link
Copy Markdown
Contributor

Can someone tell me how to access the access to the log file works in NVDA.

There are lots of examples in the file you are editing. For instance the line after your edit is:
log.debug("Loading add-on from %s", addon_path)

Essentially, you can call log.error() passing a string for the message. Coming up with a good message is the hard part. There are several log levels, you can set the log level of NVDA on the general settings panel (for development you generally want debug level logging), or with the command line option --debug-logging.

@awalvie

awalvie commented Mar 23, 2019

Copy link
Copy Markdown
Contributor Author

Can you check if this is alright ? @feerrenrut

@feerrenrut feerrenrut 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.

Looks like you are on the right track. A few suggestions here, after you have made these changes and tested again, could you also please update the testing performed section to show the steps you took to test this and how you verified that the result was correct.

Comment thread source/addonHandler/__init__.py Outdated
Comment thread source/addonHandler/__init__.py Outdated
except:
log.error("Error loading Addon from path: %s", addon_path, exc_info=True)
else:
log.error("Error loading Addon from path: %s, try reinstalling: %s", addon_path, name,exc_info=True)

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.

I don't think there is an exception active at this stage, I dont think the parameter exc_info is necessary. As mentioned in the other comment, I think it would improve the readability if this block was moved under the if statement.

I haven't yet tried this out, is it true that reinstalling will work?

@awalvie awalvie Mar 24, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes reinstalling works. What happens when you delete all the files is that the addon disappears from the addon list and you have to reinstall it. And I have changed the if condition around as you have suggested.

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.

Thanks @awalvie. Could you please update the "testing performed" section of the initial description of this PR. Please see our wiki page explaining the PR template for further information and examples on this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes definitely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any other changes you'd recommend making ?

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.

Nope, just waiting on the changes to the "testing performed" section of the initial description of this PR. Don't forget to read the wiki page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Really sorry, forgot about it. I'll do this ASAP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@feerrenrut Just updated it. Let me know if any other changes need to be done. Thanks for the feedback.

@feerrenrut feerrenrut 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.

I'll merge this in. Thanks for your work on this.

@feerrenrut feerrenrut merged commit d04614a into nvaccess:master Mar 27, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.1 milestone Mar 27, 2019
feerrenrut added a commit that referenced this pull request Mar 27, 2019
No longer crash when an addon directory is empty.
@awalvie

awalvie commented Mar 27, 2019

Copy link
Copy Markdown
Contributor Author

Thanks for all the help and suggestions.

@michaelDCurran michaelDCurran modified the milestones: 2019.1, 2019.2 Mar 27, 2019
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.

Core: Don't Refuse to Start if Add-On Manifest is Missing

6 participants