Skip to content

Commit 583b1b9

Browse files
committed
(#494) Refresh the sources from file each time
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.
1 parent 424b8fb commit 583b1b9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class ChocolateyService : IChocolateyService
3737
private static readonly AsyncReaderWriterLock Lock = new AsyncReaderWriterLock();
3838
private readonly IMapper _mapper;
3939
private readonly IProgressService _progressService;
40-
private readonly IChocolateyConfigSettingsService _configSettingsService;
4140
private readonly IXmlService _xmlService;
4241
private readonly IFileSystem _fileSystem;
4342
private readonly IConfigService _configService;
@@ -46,11 +45,10 @@ public class ChocolateyService : IChocolateyService
4645
#pragma warning disable SA1401 // Fields must be private
4746
#pragma warning restore SA1401 // Fields must be private
4847

49-
public ChocolateyService(IMapper mapper, IProgressService progressService, IChocolateyConfigSettingsService configSettingsService, IXmlService xmlService, IFileSystem fileSystem, IConfigService configService)
48+
public ChocolateyService(IMapper mapper, IProgressService progressService, IXmlService xmlService, IFileSystem fileSystem, IConfigService configService)
5049
{
5150
_mapper = mapper;
5251
_progressService = progressService;
53-
_configSettingsService = configSettingsService;
5452
_xmlService = xmlService;
5553
_fileSystem = fileSystem;
5654
_configService = configService;
@@ -497,8 +495,8 @@ public async Task<ChocolateySource[]> GetSources()
497495
// we need to read all information from the config file, i.e. the username and password
498496
var config = await GetConfigFile();
499497
var allSources = config.Sources.Select(_mapper.Map<ChocolateySource>).ToArray();
500-
501-
var filteredSourceIds = _configSettingsService.source_list(_choco.GetConfiguration()).Select(s => s.Id).ToArray();
498+
var configSettingsService = new ChocolateyConfigSettingsService(_xmlService);
499+
var filteredSourceIds = configSettingsService.source_list(_choco.GetConfiguration()).Select(s => s.Id).ToArray();
502500

503501
var mappedSources = allSources.Where(s => filteredSourceIds.Contains(s.Id)).ToArray();
504502
return mappedSources;

0 commit comments

Comments
 (0)