Skip to content
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

Make forceFresh argument in UpdateInformation optional #1990

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TgsCoreVersion>6.11.1</TgsCoreVersion>
<TgsConfigVersion>5.3.0</TgsConfigVersion>
<TgsRestVersion>10.10.0</TgsRestVersion>
<TgsGraphQLVersion>0.3.0</TgsGraphQLVersion>
<TgsGraphQLVersion>0.4.0</TgsGraphQLVersion>
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>16.1.0</TgsApiLibraryVersion>
<TgsClientVersion>19.1.0</TgsClientVersion>
Expand Down
11 changes: 6 additions & 5 deletions src/Tgstation.Server.Host/GraphQL/Types/UpdateInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public bool UpdateInProgress(
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>The <see cref="Uri"/> of the GitHub repository updates are sourced from on success. <see langword="null"/> if a GitHub API error occurred.</returns>
public async ValueTask<Uri?> TrackedRepositoryUrl(
bool forceFresh,
bool? forceFresh,
[Service] IGraphQLAuthorityInvoker<IAdministrationAuthority> administrationAuthority,
CancellationToken cancellationToken)
=> (await GetAdministrationResponseSafe(forceFresh, administrationAuthority, cancellationToken)).TrackedRepositoryUrl;
Expand All @@ -82,7 +82,7 @@ public bool UpdateInProgress(
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>The <see cref="Version"/> of the latest TGS version on success. <see langword="null"/> if a GitHub API error occurred.</returns>
public async ValueTask<Version?> LatestVersion(
bool forceFresh,
bool? forceFresh,
[Service] IGraphQLAuthorityInvoker<IAdministrationAuthority> administrationAuthority,
CancellationToken cancellationToken)
=> (await GetAdministrationResponseSafe(forceFresh, administrationAuthority, cancellationToken)).LatestVersion;
Expand All @@ -95,20 +95,21 @@ public bool UpdateInProgress(
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="AdministrationResponse"/> from the <paramref name="administrationAuthority"/>.</returns>
async ValueTask<AdministrationResponse> GetAdministrationResponseSafe(
bool forceFresh,
bool? forceFresh,
IGraphQLAuthorityInvoker<IAdministrationAuthority> administrationAuthority,
CancellationToken cancellationToken)
{
using (await SemaphoreSlimContext.Lock(cacheReadSemaphore, cancellationToken))
{
forceFresh ??= false;
if (cacheForceGenerated)
forceFresh = false;
else
cacheForceGenerated |= forceFresh;
cacheForceGenerated |= forceFresh.Value;

ArgumentNullException.ThrowIfNull(administrationAuthority);
var response = await administrationAuthority.Invoke<AdministrationResponse, AdministrationResponse>(
authority => authority.GetUpdateInformation(forceFresh, cancellationToken));
authority => authority.GetUpdateInformation(forceFresh.Value, cancellationToken));

return response;
}
Expand Down
Loading