@@ -63,10 +63,8 @@ public virtual async Task InitializeAsync()
63
63
{
64
64
Status = await LoadManager ( ) ;
65
65
66
-
67
- if ( SourceProvider != null && Status . Found )
66
+ if ( IsReady ( ) && SourceProvider != null )
68
67
{
69
-
70
68
Task < ManagerSource [ ] > SourcesTask = GetSources ( ) ;
71
69
Task winner = await Task . WhenAny (
72
70
SourcesTask ,
@@ -129,6 +127,15 @@ public bool IsEnabled()
129
127
return ! Settings . Get ( "Disable" + Name ) ;
130
128
}
131
129
130
+ /// <summary>
131
+ /// Returns true if the manager is enabled and available (the required executable files were found). Returns false otherwise
132
+ /// </summary>
133
+ /// <returns></returns>
134
+ public bool IsReady ( )
135
+ {
136
+ return IsEnabled ( ) && Status . Found ;
137
+ }
138
+
132
139
/// <summary>
133
140
/// Returns an array of Package objects that the manager lists for the given query. Depending on the manager, the list may
134
141
/// also include similar results. This method is fail-safe and will return an empty array if an error occurs.
@@ -137,6 +144,7 @@ public bool IsEnabled()
137
144
/// <returns></returns>
138
145
public async Task < Package [ ] > FindPackages ( string query )
139
146
{
147
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet FindPackages was called") ; return [ ] ; } ;
140
148
try
141
149
{
142
150
Package [ ] packages = await FindPackages_UnSafe ( query ) ;
@@ -163,6 +171,7 @@ public async Task<Package[]> FindPackages(string query)
163
171
/// <returns></returns>
164
172
public async Task < Package [ ] > GetAvailableUpdates ( )
165
173
{
174
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet GetAvailableUpdates was called") ; return [ ] ; } ;
166
175
try
167
176
{
168
177
await RefreshPackageIndexes ( ) ;
@@ -187,6 +196,7 @@ public async Task<Package[]> GetAvailableUpdates()
187
196
/// <returns></returns>
188
197
public async Task < Package [ ] > GetInstalledPackages ( )
189
198
{
199
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet GetInstalledPackages was called") ; return [ ] ; } ;
190
200
try
191
201
{
192
202
Package [ ] packages = await GetInstalledPackages_UnSafe ( ) ;
@@ -348,6 +358,7 @@ public OperationVeredict GetRemoveSourceOperationVeredict(ManagerSource source,
348
358
}
349
359
public virtual async Task < ManagerSource [ ] > GetSources ( )
350
360
{
361
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet GetSources was called") ; return [ ] ; } ;
351
362
try
352
363
{
353
364
AssertSourceCompatibility ( "GetSources" ) ;
@@ -381,6 +392,7 @@ private void AssertPackageDetailsCompatibility(string MethodName)
381
392
#pragma warning disable CS8602
382
393
public async Task < PackageDetails > GetPackageDetails ( Package package )
383
394
{
395
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet GetPackageDetails was called") ; return new ( package ) ; } ;
384
396
try
385
397
{
386
398
AssertPackageDetailsCompatibility ( "GetPackageDetails" ) ;
@@ -398,6 +410,7 @@ public async Task<PackageDetails> GetPackageDetails(Package package)
398
410
399
411
public async Task < string [ ] > GetPackageVersions ( Package package )
400
412
{
413
+ if ( ! IsReady ( ) ) { Logger . Warn ( $ "Manager { Name } is disabled but yet GetPackageVersions was called") ; return [ ] ; } ;
401
414
try
402
415
{
403
416
AssertPackageDetailsCompatibility ( "GetPackageVersions" ) ;
0 commit comments