Skip to content

Commit

Permalink
Fix featured mod file URL
Browse files Browse the repository at this point in the history
Fixes #183
  • Loading branch information
micheljung committed Nov 29, 2017
1 parent be93c22 commit 7d57715
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/faforever/api/featuredmods/FeaturedModFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.faforever.api.featuredmods;

import com.yahoo.elide.annotation.Exclude;
import lombok.Setter;
import org.hibernate.annotations.Immutable;

Expand All @@ -21,7 +22,9 @@ public class FeaturedModFile {
private String group;
private String md5;
private String name;
private String originalFileName;
private int version;
// Enriched in FeaturedModFileEnricher
private String url;
private String folderName;
private short fileId;
Expand All @@ -42,11 +45,24 @@ public String getMd5() {
return md5;
}

/**
* Name of the file on the client's file system.
*/
@Column(name = "name")
public String getName() {
return name;
}


/**
* Name of the file on the server's file system.
*/
@Column(name = "fileName")
@Exclude
public String getOriginalFileName() {
return originalFileName;
}

@Column(name = "version")
public int getVersion() {
return version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public void init(FafApiProperties fafApiProperties) {

@PostLoad
public void enhance(FeaturedModFile featuredModFile) {
String filename = featuredModFile.getName();
String folder = featuredModFile.getFolderName();
String urlFormat = fafApiProperties.getFeaturedMod().getFileUrlFormat();

featuredModFile.setUrl(String.format(urlFormat, folder, filename));
featuredModFile.setUrl(String.format(urlFormat, folder, featuredModFile.getOriginalFileName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<FeaturedModFile> getFiles(String modName, Integer version) {
" file.md5 AS `md5`," +
" file.fileId AS `fileId`," +
" file.id AS `id`," +
" file.name AS `url`," +
" file.name AS `fileName`," +
" 'updates_%1$s_files' AS `folderName`" +
"FROM updates_%1$s_files file" +
" INNER JOIN" +
Expand Down

0 comments on commit 7d57715

Please sign in to comment.