@@ -14,32 +14,55 @@ public class GithubPluginUpdater(Lazy<Version> version) {
14
14
15
15
private Version CurrentVersion => version . Value ;
16
16
17
+ private static void LogGenericError ( string message ) {
18
+ if ( string . IsNullOrEmpty ( message ) ) {
19
+ return ;
20
+ }
21
+
22
+ ArchiSteamFarm . Core . ASF . ArchiLogger . LogGenericError ( $ "{ nameof ( GithubPluginUpdater ) } : { message } ") ;
23
+ }
24
+
25
+ private static void LogGenericDebug ( string message ) {
26
+ if ( string . IsNullOrEmpty ( message ) ) {
27
+ return ;
28
+ }
29
+
30
+ ArchiSteamFarm . Core . ASF . ArchiLogger . LogGenericDebug ( $ "{ nameof ( GithubPluginUpdater ) } : { message } ") ;
31
+ }
32
+
17
33
public async Task < Uri ? > GetTargetReleaseURL ( Version asfVersion , string asfVariant , bool asfUpdate , bool stable , bool forced ) {
18
34
ArgumentNullException . ThrowIfNull ( asfVersion ) ;
19
35
ArgumentException . ThrowIfNullOrEmpty ( asfVariant ) ;
20
36
21
37
if ( ! CanUpdate ) {
38
+ LogGenericDebug ( "CanUpdate is false" ) ;
39
+
22
40
return null ;
23
41
}
24
42
25
43
if ( string . IsNullOrEmpty ( RepositoryName ) ) {
26
- //ArchiSteamFarm.Core.ASF.ArchiLogger. LogGenericError(Strings.FormatWarningFailedWithError(nameof( RepositoryName)) );
44
+ LogGenericError ( " RepositoryName is null or empty" ) ;
27
45
28
46
return null ;
29
47
}
30
48
31
49
ReleaseResponse ? releaseResponse = await GitHubService . GetLatestRelease ( RepositoryName ) . ConfigureAwait ( false ) ;
32
50
33
51
if ( releaseResponse == null ) {
52
+ LogGenericError ( "GetLatestRelease returned null" ) ;
53
+
34
54
return null ;
35
55
}
36
56
37
57
if ( releaseResponse . IsPreRelease ) {
58
+ LogGenericError ( "GetLatestRelease returned pre-release" ) ;
59
+
38
60
return null ;
39
61
}
40
62
41
- if ( stable && ! ( ( releaseResponse . PublishedAt - DateTime . UtcNow ) . Duration ( ) > TimeSpan . FromHours ( 3 ) ) ) {
42
- // Skip updates that are too recent
63
+ if ( stable && ( ( releaseResponse . PublishedAt - DateTime . UtcNow ) . Duration ( ) < TimeSpan . FromHours ( 3 ) ) ) {
64
+ LogGenericDebug ( "GetLatestRelease returned too recent" ) ;
65
+
43
66
return null ;
44
67
}
45
68
@@ -48,27 +71,25 @@ public class GithubPluginUpdater(Lazy<Version> version) {
48
71
if ( ! forced && ( CurrentVersion >= newVersion ) ) {
49
72
// Allow same version to be re-updated when we're updating ASF release and more than one asset is found - potential compatibility difference
50
73
if ( ( CurrentVersion > newVersion ) || ! asfUpdate || ( releaseResponse . Assets . Count ( static asset => asset . Name . EndsWith ( ".zip" , StringComparison . OrdinalIgnoreCase ) ) < 2 ) ) {
51
- //ASF.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateNotFound(Name, Version, newVersion));
52
-
53
74
return null ;
54
75
}
55
76
}
56
77
57
78
if ( releaseResponse . Assets . Count == 0 ) {
58
- //ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateNoAssetFound(Name, Version, newVersion) );
79
+ LogGenericError ( $ "GetLatestRelease for version { newVersion } returned no assets" ) ;
59
80
60
81
return null ;
61
82
}
62
83
63
84
ReleaseAsset ? asset = releaseResponse . Assets . FirstOrDefault ( static asset => asset . Name . EndsWith ( ".zip" , StringComparison . OrdinalIgnoreCase ) && ( asset . Size > ( 1 << 18 ) ) ) ;
64
85
65
86
if ( ( asset == null ) || ! releaseResponse . Assets . Contains ( asset ) ) {
66
- //ASF.ArchiLogger.LogGenericWarning(Strings.FormatPluginUpdateNoAssetFound(Name, Version, newVersion) );
87
+ LogGenericError ( $ "GetLatestRelease for version { newVersion } returned no valid assets" ) ;
67
88
68
89
return null ;
69
90
}
70
91
71
- //.ArchiLogger.LogGenericInfo(Strings.FormatPluginUpdateFound( Name, Version, newVersion) );
92
+ LogGenericDebug ( $ "GetLatestRelease for version { newVersion } returned asset { asset . Name } with url { asset . DownloadURL } " ) ;
72
93
73
94
return asset . DownloadURL ;
74
95
}
0 commit comments