Skip to content

Commit 726defb

Browse files
committed
Add DOWNLOAD_MISSING_BEATMAPS env var
1 parent 483ab50 commit 726defb

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Difficalcy/Services/WebBeatmapProvider.cs

+4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ namespace Difficalcy.Services
99
public class WebBeatmapProvider(IConfiguration configuration) : IBeatmapProvider
1010
{
1111
private readonly string _beatmapDirectory = configuration["BEATMAP_DIRECTORY"];
12+
private readonly string _downloadMissingBeatmaps = configuration["DOWNLOAD_MISSING_BEATMAPS"];
1213
private readonly HttpClient _httpClient = new();
1314

1415
public async Task EnsureBeatmap(string beatmapId)
1516
{
1617
var beatmapPath = GetBeatmapPath(beatmapId);
1718
if (!File.Exists(beatmapPath))
1819
{
20+
if (_downloadMissingBeatmaps != "true")
21+
throw new BadHttpRequestException("Beatmap not found");
22+
1923
using var response = await _httpClient.GetAsync($"https://osu.ppy.sh/osu/{beatmapId}");
2024
if (!response.IsSuccessStatusCode || response.Content.Headers.ContentLength == 0)
2125
throw new BadHttpRequestException("Beatmap not found");

Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ LABEL org.opencontainers.image.source https://github.com/Syriiin/difficalcy
44

55
WORKDIR /app
66
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"
1011

1112
VOLUME ${BEATMAP_DIRECTORY}
1213
# chmod 777 so that this volume can be read/written by other containers that might use different uids

docs/docs/configuration.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ However it would be a good idea to consider these configuration options for a re
66

77
## Environment Variables
88

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. |
1213

1314
## Docker volumes
1415

0 commit comments

Comments
 (0)