-
Notifications
You must be signed in to change notification settings - Fork 255
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
(#494) Refresh sources from file #955
Draft
corbob
wants to merge
5
commits into
chocolatey:develop
Choose a base branch
from
corbob:refresh-sources-from-file
base: develop
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.
Draft
+75
−4
Conversation
This file contains 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
corbob
force-pushed
the
refresh-sources-from-file
branch
3 times, most recently
from
September 2, 2022 03:33
7ca4fe9
to
ca20e8d
Compare
Sometimes (it looks like maybe when the Chocolatey Licensed Extension is in play) we don't get the sources currently in the configuration file. If instead of reusing the configuration settings service we instantiate a new one each time, then it will ensure the configuration file is read again. This resolves the issue of settings not applying in GUI if they're made while GUI is running.
When Chocolatey CLI makes changes to the configuration file while Chocolatey GUI is running, Chocolatey GUI should refresh the sources so that they're accurate. This adds a FileSystemWatcher to monitor the configuration file and update the GUI if there's updates to the file.
With the FileSystemWatcher, we don't need to manually tell Chocolatey GUI to update the sources, as they'll be updated by the FileSystemWatcher. Leaving them in results in duplicated entries that we don't want.
corbob
force-pushed
the
refresh-sources-from-file
branch
from
September 2, 2022 18:48
ca20e8d
to
dcb3405
Compare
gep13
requested changes
Sep 6, 2022
Source/ChocolateyGui.Common.Windows/Services/ConfigFileWatcher.cs
Outdated
Show resolved
Hide resolved
Source/ChocolateyGui.Common.Windows/Services/ConfigFileWatcher.cs
Outdated
Show resolved
Hide resolved
Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs
Outdated
Show resolved
Hide resolved
Renamed configuration file variable to indicate it's the path to the configuration file. Made ConfigFileChanged public and added it to the interface. Also renamed it to OnConfigFileChanged as that seems to be a better name to indicate it's the action for when the file changes.
This reverts commit 583b1b9.
After reverting commit 583b1b9 I performed the tests in the PR. My observations are:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description Of Changes
Update to get sources from the configuration file every time they're requested.
Motivation and Context
When the sources are updated outside of Chocolatey GUI (or within Chocolatey GUI when Chocolatey Licensed Extension is installed), only the sources that were present when Chocolatey GUI started are loaded, no new sources are found.
Testing
Note: Because Chocolatey GUI interacts with Chocolatey through the Chocolatey library, and because there are extensions that can change behaviour, all testing should be done with Chocolatey CLI, then with Chocolatey Licensed Extension installed, and finally with Chocolatey GUI Licensed Extension installed. The below steps were taken with each of those configurations.
Chocolatey Licensed Extension Note: I have noted in my testing that if you install Licensed Extension, then immediately open Chocolatey GUI without running
choco
beforehand, you end up with a duplicated list of remote sources on the left. Any action that makes changes to the Chocolatey config file will correct this duplication. I believe this is due to the list being updated on application load, and since that (effectively) runschoco
, the config is updated with the Licensed Extension configurations which fires the FileSystemWatcher and results in a second refresh occurring in rapid succession. This is the only time I have been able to get this behaviour to occur since correcting it in the FileSystemWatcher.choco sources list
choco source add -n test -s c:\
test
sourcechoco source disable -n test
test
sourcetest
source is there, but disabled.test
source and navigate back to Chocolatey GUItest
is back in the listchoco source remove -n test
test
is removed from the list on the left panel of Chocolatey GUItest
source is no longer thereChocolatey Licensed Extension specific tests
Due to some of the restrictions that the Chocolatey Licensed Extension provides, we need to test the following with the Licensed Extension, and with the Chocolatey GUI Licensed Extension. Use the following code to setup a few settings:
With Chocolatey configured, perform the following tests:
self-serve
source is the only source listed on the leftchoco source disable -n self-serve
choco source enable -n self-serve
choco source add -n new-self-serve -s c\temp --allowselfservice
choco source add -n admin-only -s c:\temp
admin-only
source should appear in the left of Chocolatey GUIChange Types Made
Related Issue
Fixes #494
Change Checklist