Commit 726defb 1 parent 483ab50 commit 726defb Copy full SHA for 726defb
File tree 3 files changed +12
-6
lines changed
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,17 @@ namespace Difficalcy.Services
9
9
public class WebBeatmapProvider ( IConfiguration configuration ) : IBeatmapProvider
10
10
{
11
11
private readonly string _beatmapDirectory = configuration [ "BEATMAP_DIRECTORY" ] ;
12
+ private readonly string _downloadMissingBeatmaps = configuration [ "DOWNLOAD_MISSING_BEATMAPS" ] ;
12
13
private readonly HttpClient _httpClient = new ( ) ;
13
14
14
15
public async Task EnsureBeatmap ( string beatmapId )
15
16
{
16
17
var beatmapPath = GetBeatmapPath ( beatmapId ) ;
17
18
if ( ! File . Exists ( beatmapPath ) )
18
19
{
20
+ if ( _downloadMissingBeatmaps != "true" )
21
+ throw new BadHttpRequestException ( "Beatmap not found" ) ;
22
+
19
23
using var response = await _httpClient . GetAsync ( $ "https://osu.ppy.sh/osu/{ beatmapId } ") ;
20
24
if ( ! response . IsSuccessStatusCode || response . Content . Headers . ContentLength == 0 )
21
25
throw new BadHttpRequestException ( "Beatmap not found" ) ;
Original file line number Diff line number Diff line change @@ -4,9 +4,10 @@ LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy
4
4
5
5
WORKDIR /app
6
6
EXPOSE 80
7
- ENV ASPNETCORE_URLS=http://+:80
8
- ENV ASPNETCORE_ENVIRONMENT=Production
9
- ENV BEATMAP_DIRECTORY=/beatmaps
7
+ ENV ASPNETCORE_URLS="http://+:80"
8
+ ENV ASPNETCORE_ENVIRONMENT="Production"
9
+ ENV BEATMAP_DIRECTORY="/beatmaps"
10
+ ENV DOWNLOAD_MISSING_BEATMAPS="true"
10
11
11
12
VOLUME ${BEATMAP_DIRECTORY}
12
13
# chmod 777 so that this volume can be read/written by other containers that might use different uids
Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ However it would be a good idea to consider these configuration options for a re
6
6
7
7
## Environment Variables
8
8
9
- | Environment variable | Default | Description |
10
- | --------------------- | ------- | ----------------------------------------------------------------------------------------------- |
11
- | ` REDIS_CONFIGURATION ` | | The address of the redis server to use for beatmap caching. By default, there will be no cache. |
9
+ | Environment variable | Default | Description |
10
+ | --------------------------- | ------- | ----------------------------------------------------------------------------------------------- |
11
+ | ` REDIS_CONFIGURATION ` | | The address of the redis server to use for beatmap caching. By default, there will be no cache. |
12
+ | ` DOWNLOAD_MISSING_BEATMAPS ` | true | Whether or not to attempt to download missing beatmaps. |
12
13
13
14
## Docker volumes
14
15
You can’t perform that action at this time.
0 commit comments