We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39eea66 commit 9e436a8Copy full SHA for 9e436a8
8 files changed
compose.yaml
@@ -16,7 +16,7 @@ services:
16
- "3306:3306"
17
18
faf-db-migrations:
19
- image: faforever/faf-db-migrations:v140
+ image: faforever/faf-db-migrations:v144
20
command: migrate
21
environment:
22
FLYWAY_URL: jdbc:mysql://faf-db/faf?useSSL=false
@@ -35,7 +35,7 @@ services:
35
condition: service_completed_successfully
36
37
minio:
38
- image: docker.io/bitnami/minio:2025
+ image: docker.io/alpine/minio:latest-release
39
ports:
40
- '9000:9000'
41
- '9001:9001'
src/inttest/java/com/faforever/api/config/MainDbTestContainers.java
@@ -21,7 +21,7 @@
@Configuration
public class MainDbTestContainers {
23
private static final MariaDBContainer<?> fafDBContainer = new MariaDBContainer<>("mariadb:11.7");
24
- private static final GenericContainer<?> flywayMigrationsContainer = new GenericContainer<>("faforever/faf-db-migrations:v140");
+ private static final GenericContainer<?> flywayMigrationsContainer = new GenericContainer<>("faforever/faf-db-migrations:v144");
25
private static final Network sharedNetwork = Network.newNetwork();
26
27
@Bean
src/inttest/resources/sql/prepMapData.sql
@@ -2,9 +2,9 @@ INSERT INTO map (id, display_name, map_type, battle_type, author, license) VALUE
2
(1, 'SCMP_001', 'FFA', 'skirmish', 1, 1),
3
(2, 'SCMP_002', 'FFA', 'skirmish', 1, 1);
4
5
-INSERT INTO map_version (id, description, max_players, width, height, version, filename, hidden, map_id) VALUES
6
- (1, 'SCMP 001', 8, 5, 5, 1, 'maps/scmp_001.v0001.zip', 0, 1),
7
- (2, 'SCMP 002', 8, 5, 5, 1, 'maps/scmp_002.v0001.zip', 0, 2);
+INSERT INTO map_version (id, description, max_players, width, height, version, folder_name, hidden, map_id) VALUES
+ (1, 'SCMP 001', 8, 5, 5, 1, 'scmp_001.v0001', 0, 1),
+ (2, 'SCMP 002', 8, 5, 5, 1, 'scmp_002.v0001', 0, 2);
8
9
INSERT INTO map_pool (id, name) VALUES
10
(1, 'Ladder 1v1 <300'),
src/inttest/resources/sql/prepMapVersion.sql
@@ -1,6 +1,6 @@
1
INSERT INTO map (id, display_name, map_type, battle_type, author, recommended, license) VALUES (1, 'display name', 'mtype', 'btype', 1, false, 1);
-INSERT INTO map_version (id, description, max_players, width, height, version, filename, map_id, hidden, ranked)
-VALUES (1, 'des', 2, 2, 2, 1, 'map/ghb.zip', 1, 0, 1);
+INSERT INTO map_version (id, description, max_players, width, height, version, folder_name, map_id, hidden, ranked)
+VALUES (1, 'des', 2, 2, 2, 1, 'ghb', 1, 0, 1);
INSERT INTO map_reviews_summary (id, map_id, positive, negative, score, reviews, lower_bound)
VALUES (1, 1, 0, 0, 2, 1, 0);
INSERT INTO map_version_reviews_summary (id, map_version_id, positive, negative, score, reviews, lower_bound)
src/main/java/com/faforever/api/data/domain/MapVersion.java
@@ -11,6 +11,8 @@
11
import com.yahoo.elide.annotation.Include;
12
import com.yahoo.elide.annotation.UpdatePermission;
13
import lombok.Setter;
14
+import org.hibernate.annotations.Generated;
15
+import org.hibernate.generator.EventType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -82,8 +84,10 @@ public int getVersion() {
82
84
return version;
83
85
}
86
- @Column(name = "filename")
- @NotNull
87
+ // DB-generated from folderName (CONCAT('maps/', folder_name, '.zip')); read-only here.
88
+ // No @NotNull: bean validation runs pre-insert before the DB populates this value.
89
+ @Column(name = "filename", insertable = false, updatable = false)
90
+ @Generated(event = EventType.INSERT)
91
public String getFilename() {
92
return filename;
93
@@ -138,8 +142,10 @@ public String getDownloadUrl() {
138
142
return downloadUrl;
139
143
140
144
141
- @Transient
- @ComputedAttribute
145
+ // Immutable after insert: the DB-generated filename and the derived download/
146
+ // thumbnail URLs are all computed from this, so it must not change post-creation.
147
+ @Column(name = "folder_name", updatable = false)
148
+ @NotNull
149
public String getFolderName() {
150
return folderName;
151
src/main/java/com/faforever/api/data/listeners/MapVersionEnricher.java
@@ -25,11 +25,10 @@ public void init(FafApiProperties apiProperties, EntityCacheEvictor cacheEvictor
@PostLoad
public void enhance(MapVersion mapVersion) {
28
- String filename = mapVersion.getFilename();
29
- mapVersion.setDownloadUrl(String.format(apiProperties.getMap().getDownloadUrlFormat(), filename.replace("maps/", "")));
30
- mapVersion.setThumbnailUrlLarge(String.format(apiProperties.getMap().getLargePreviewsUrlFormat(), filename.replace("maps/", "").replace(".zip", ".png")));
31
- mapVersion.setThumbnailUrlSmall(String.format(apiProperties.getMap().getSmallPreviewsUrlFormat(), filename.replace("maps/", "").replace(".zip", ".png")));
32
- mapVersion.setFolderName(filename.substring(filename.indexOf('/') + 1, filename.indexOf(".zip")));
+ String folderName = mapVersion.getFolderName();
+ mapVersion.setDownloadUrl(String.format(apiProperties.getMap().getDownloadUrlFormat(), folderName + ".zip"));
+ mapVersion.setThumbnailUrlLarge(String.format(apiProperties.getMap().getLargePreviewsUrlFormat(), folderName + ".png"));
+ mapVersion.setThumbnailUrlSmall(String.format(apiProperties.getMap().getSmallPreviewsUrlFormat(), folderName + ".png"));
33
34
@PostUpdate
src/main/java/com/faforever/api/map/MapService.java
@@ -85,7 +85,6 @@ public class MapService {
};
private static final Charset MAP_CHARSET = StandardCharsets.ISO_8859_1;
- private static final String LEGACY_FOLDER_PREFIX = "maps/";
private final FafApiProperties fafApiProperties;
private final MapRepository mapRepository;
private final LicenseRepository licenseRepository;
@@ -413,7 +412,7 @@ private Map updateHibernateMapEntities(MapLuaAccessor mapLua, Optional<Map> exis
413
412
.setMaxPlayers(standardTeamsConfig.get(CONFIGURATION_STANDARD_TEAMS_ARMIES).length())
414
.setVersion(mapLua.getMapVersion$())
415
.setMap(map)
416
- .setFilename(LEGACY_FOLDER_PREFIX + mapNameBuilder.buildFinalZipName(mapLua.getMapVersion$()));
+ .setFolderName(mapNameBuilder.buildFolderName(mapLua.getMapVersion$()));
417
418
map.getVersions().add(version);
419
src/test/java/com/faforever/api/map/MapServiceTest.java
@@ -410,7 +410,7 @@ void positiveUploadTest() throws Exception {
410
assertEquals(256, mapVersion.getHeight());
411
assertEquals(256, mapVersion.getWidth());
assertEquals(8, mapVersion.getMaxPlayers());
- assertEquals("maps/command_conquer_rush.v0007.zip", mapVersion.getFilename());
+ assertEquals("command_conquer_rush.v0007", mapVersion.getFolderName());
assertFalse(Files.exists(tmpDir));
0 commit comments