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) runs choco, 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.
Open a PowerShell window as administrator and Chocolatey GUI
Position them such that you can see Chocolatey GUI and the PowerShell window with minimal overlap
Run choco sources list
Note that the list of enabled sources matches the left panel of Chocolatey GUI
Run choco source add -n test -s c:\
Note that Chocolatey GUI left panel updates with new test source
Run choco source disable -n test
Note that Chocolatey GUI left panel updates without the test source
Navigate to Settings > Sources in Chocolatey GUI
Note that test source is there, but disabled.
Enable test source and navigate back to Chocolatey GUI
Note that test is back in the list
Run choco source remove -n test
Note that test is removed from the list on the left panel of Chocolatey GUI
Navigate to Settings > Sources in Chocolatey GUI
Note that test source is no longer there
Close Chocolatey GUI
Chocolatey 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:
After reverting commit 583b1b9f160a92df7b1ea9d39ddc46bf28a7949b I performed the tests in the PR. My observations are:
With Just Chocolatey CLI installed, all existing sources in the file when Chocolatey GUI is launched successfully maintain state. If you enable or disable them outside of Chocolatey GUI, they are updated inside of Chocolatey GUI. However, if you add a new source, it fails to be detected.
With Chocolatey Licensed Extension installed, the tests behaved the same as Chocolatey CLI. The Licensed specific tests however did not work as desired. The only change that was correctly picked up is enable, disable, or removal of an existing source. Changes to the Admin Only or Self Serve status does not get reflected.
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