11using Gommon ;
22using Microsoft . AspNetCore . Mvc ;
33using Ryujinx . Systems . Update . Common ;
4- using Ryujinx . Systems . Update . Server ;
54using Ryujinx . Systems . Update . Server . Services . GitLab ;
65
76namespace Ryujinx . Systems . Update . Server . Controllers ;
@@ -14,7 +13,7 @@ public class DownloadController : ControllerBase
1413 [ ProducesResponseType ( StatusCodes . Status302Found ) ]
1514 [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
1615 [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
17- public async Task < ActionResult < object > > DownloadLatestCustom (
16+ public async Task < ActionResult < object > > DownloadCustom (
1817 [ FromQuery ] string os ,
1918 [ FromQuery ] string arch ,
2019 [ FromQuery ] string rc = Constants . StableRoute ,
@@ -39,13 +38,11 @@ public async Task<ActionResult<object>> DownloadLatestCustom(
3938 if ( ! rc . TryParseAsReleaseChannel ( out var releaseChannel ) )
4039 return BadRequest ( $ "Unknown release channel '{ rc } '; valid are '{ Constants . StableRoute } ' and '{ Constants . CanaryRoute } '") ;
4140
42- var versionCache = HttpContext . RequestServices . GetCacheFor ( releaseChannel ) ;
43-
44- var lck = await versionCache . TakeLockAsync ( ) ;
45-
46- var release = version is Constants . RouteName_Latest ? versionCache . Latest : versionCache [ version ] ;
47-
48- lck . Dispose ( ) ;
41+ var release = await HttpContext . RequestServices
42+ . GetCacheFor ( releaseChannel )
43+ . GetReleaseAsync ( c =>
44+ version is Constants . RouteName_Latest ? c . Latest : c [ version ]
45+ ) ;
4946
5047 if ( release is null )
5148 return NotFound ( ) ;
@@ -61,11 +58,7 @@ public async Task<ActionResult<object>> DownloadLatestStable(
6158 [ FromKeyedServices ( "stableCache" ) ] VersionCache vcache
6259 )
6360 {
64- var lck = await vcache . TakeLockAsync ( ) ;
65-
66- var latest = vcache . Latest ;
67-
68- lck . Dispose ( ) ;
61+ var latest = await vcache . GetReleaseAsync ( c => c . Latest ) ;
6962
7063 if ( latest is null )
7164 return NotFound ( ) ;
@@ -91,11 +84,7 @@ public async Task<ActionResult<object>> DownloadLatestCanary(
9184 [ FromKeyedServices ( "canaryCache" ) ] VersionCache vcache
9285 )
9386 {
94- var lck = await vcache . TakeLockAsync ( ) ;
95-
96- var latest = vcache . Latest ;
97-
98- lck . Dispose ( ) ;
87+ var latest = await vcache . GetReleaseAsync ( c => c . Latest ) ;
9988
10089 if ( latest is null )
10190 return NotFound ( ) ;
0 commit comments