diff --git a/build.gradle b/build.gradle index f58f812d1..d9fffcd3a 100644 --- a/build.gradle +++ b/build.gradle @@ -109,7 +109,7 @@ apply plugin: 'org.springframework.boot' apply plugin: 'propdeps' group = 'faforever' -version = '0.8.0' +version = '0.8.1' sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/src/main/java/com/faforever/api/data/domain/FeaturedMod.java b/src/main/java/com/faforever/api/data/domain/FeaturedMod.java index 5adfdc518..962c5b0af 100644 --- a/src/main/java/com/faforever/api/data/domain/FeaturedMod.java +++ b/src/main/java/com/faforever/api/data/domain/FeaturedMod.java @@ -21,7 +21,7 @@ public class FeaturedMod { private int order; private String gitUrl; private String gitBranch; - private Boolean replaceExisting; + private Boolean allowOverride; private String fileExtension; @Id @@ -65,9 +65,9 @@ public String getGitBranch() { return gitBranch; } - @Column(name = "replace_existing") - public Boolean isReplaceExisting() { - return replaceExisting; + @Column(name = "allow_override") + public Boolean isAllowOverride() { + return allowOverride; } @Column(name = "file_extension") diff --git a/src/main/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTask.java b/src/main/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTask.java index 9315e910d..4220208c5 100644 --- a/src/main/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTask.java +++ b/src/main/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTask.java @@ -79,18 +79,18 @@ public void run() { String repositoryUrl = featuredMod.getGitUrl(); String branch = featuredMod.getGitBranch(); - boolean replaceExisting = featuredMod.isReplaceExisting(); + boolean allowOverride = featuredMod.isAllowOverride(); String modFilesExtension = featuredMod.getFileExtension(); Map fileIds = featuredModService.getFileIds(modName); - log.info("Starting deployment of '{}' from '{}', branch '{}', replaceExisting '{}', modFilesExtension '{}'", - modName, repositoryUrl, branch, replaceExisting, modFilesExtension); + log.info("Starting deployment of '{}' from '{}', branch '{}', allowOverride '{}', modFilesExtension '{}'", + modName, repositoryUrl, branch, allowOverride, modFilesExtension); Path repositoryDirectory = buildRepositoryDirectoryPath(repositoryUrl); checkoutCode(repositoryDirectory, repositoryUrl, branch); short version = readModVersion(repositoryDirectory); - verifyVersion(version, replaceExisting, modName); + verifyVersion(version, allowOverride, modName); Deployment deployment = apiProperties.getDeployment(); Path targetFolder = Paths.get(deployment.getFeaturedModsTargetDirectory(), String.format(deployment.getFilesDirectoryFormat(), modName)); @@ -134,8 +134,8 @@ private short readModVersion(Path modPath) { return (short) Integer.parseInt(new ModReader().readDirectory(modPath).getVersion().toString()); } - private void verifyVersion(int version, boolean replaceExisting, String modName) { - if (!replaceExisting) { + private void verifyVersion(int version, boolean allowOverride, String modName) { + if (!allowOverride) { // Normally I'd create a proper query, but this is a hotfix and a protest against the DB-driven patcher // Luckily, BiReUS is coming "soon". OptionalInt existingVersion = featuredModService.getFiles(modName, version).stream() @@ -153,7 +153,7 @@ private void updateDatabase(List files, short version, String modNam List featuredModFiles = files.stream() .map(file -> new FeaturedModFile() .setMd5(noCatch(() -> hash(file.getTargetFile().toFile(), md5())).toString()) - .setFileId(file.getFileId()) + .setFileId((short) file.getFileId()) .setName(file.getTargetFile().getFileName().toString()) .setVersion(version) ) @@ -279,7 +279,7 @@ private class StagedFile { /** * ID of the file as stored in the database. */ - private final int fileId; + private final short fileId; /** * The staged file, already in the correct location, that is ready to be renamed. */ diff --git a/src/main/java/com/faforever/api/featuredmods/FeaturedModFile.java b/src/main/java/com/faforever/api/featuredmods/FeaturedModFile.java index 1a4e99e3a..a5c9b5d04 100644 --- a/src/main/java/com/faforever/api/featuredmods/FeaturedModFile.java +++ b/src/main/java/com/faforever/api/featuredmods/FeaturedModFile.java @@ -13,7 +13,7 @@ @Immutable @Entity @EntityListeners(FeaturedModFileEnricher.class) -// Thanks to the dynamic table nature of the legacy updater, this class is not mapped to an underlying database but +// Thanks to the dynamic table nature of the legacy updater, this class is not mapped to an underlying table but // a native query instead. This is why the columns here can't be found in any table. public class FeaturedModFile { @@ -21,10 +21,10 @@ public class FeaturedModFile { private String group; private String md5; private String name; - private short version; + private int version; private String url; private String folderName; - private int fileId; + private short fileId; @Id @Column(name = "id") @@ -48,12 +48,12 @@ public String getName() { } @Column(name = "version") - public short getVersion() { + public int getVersion() { return version; } @Column(name = "fileId") - public int getFileId() { + public short getFileId() { return fileId; } diff --git a/src/main/resources/config/application-prod.yml b/src/main/resources/config/application-prod.yml index 5b026eea5..f593eae7b 100644 --- a/src/main/resources/config/application-prod.yml +++ b/src/main/resources/config/application-prod.yml @@ -29,8 +29,6 @@ faf-api: mandrill-api-key: ${MANDRILL_API_KEY} clan: website-url-format: ${CLAN_WEBSITE_URL_FORMAT} - challonge: - key: ${CHALLONGE_KEY:} spring: datasource: diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 9dc6ea4c8..8fda87b97 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -8,6 +8,8 @@ faf-api: html-format:

Dear %1$s,

welcome to the Forged Alliance Forever community. Please visit the following link to activate your account:

%2$s

-- The Forged Alliance Forever team.

clan: invite-link-expire-duration-minutes: ${CLAN_INVITE_LINK_EXPIRE_DURATION_MINUTES:604800} + challonge: + key: ${CHALLONGE_KEY:} spring: application: diff --git a/src/test/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTaskTest.java b/src/test/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTaskTest.java index dac524e90..aa9e1b76b 100644 --- a/src/test/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTaskTest.java +++ b/src/test/java/com/faforever/api/deployment/LegacyFeaturedModDeploymentTaskTest.java @@ -71,15 +71,15 @@ public void testRunNoFileIds() throws Exception { .setGitBranch("branch") .setFileExtension("nx3") .setTechnicalName("faf") - .setReplaceExisting(true) + .setAllowOverride(true) .setGitUrl("git@example.com/FAForever/faf")); Mockito.doAnswer(invocation -> { Path repoFolder = invocation.getArgument(0); Files.createDirectories(repoFolder.resolve("someDir")); Files.copy( - LegacyFeaturedModDeploymentTaskTest.class.getResourceAsStream("/featured_mod/mod_info.lua"), - repoFolder.resolve("mod_info.lua") + LegacyFeaturedModDeploymentTaskTest.class.getResourceAsStream("/featured_mod/mod_info.lua"), + repoFolder.resolve("mod_info.lua") ); return null; }).when(gitWrapper).checkoutRef(any(), any()); @@ -105,18 +105,18 @@ public void testRun() throws Exception { .setGitBranch("branch") .setFileExtension("nx3") .setTechnicalName("faf") - .setReplaceExisting(true) + .setAllowOverride(true) .setGitUrl("git@example.com/FAForever/faf")); Mockito.doAnswer(invocation -> { Path repoFolder = invocation.getArgument(0); Files.createDirectories(repoFolder.resolve("someDir")); Files.copy( - LegacyFeaturedModDeploymentTaskTest.class.getResourceAsStream("/featured_mod/mod_info.lua"), - repoFolder.resolve("mod_info.lua") + LegacyFeaturedModDeploymentTaskTest.class.getResourceAsStream("/featured_mod/mod_info.lua"), + repoFolder.resolve("mod_info.lua") ); Files.copy(LegacyFeaturedModDeploymentTaskTest.class.getResourceAsStream("/featured_mod/someDir/someFile"), - repoFolder.resolve("someDir/someFile") + repoFolder.resolve("someDir/someFile") ); return null; }).when(gitWrapper).checkoutRef(any(), any()); @@ -125,8 +125,8 @@ public void testRun() throws Exception { new FeaturedMod().setTechnicalName("faf") )); when(featuredModService.getFileIds("faf")).thenReturn(ImmutableMap.of( - "ForgedAlliance.exe", (short) 1, - "someDir.nx3", (short) 2 + "ForgedAlliance.exe", (short) 1, + "someDir.nx3", (short) 2 )); Path dummyExe = repositoriesFolder.getRoot().toPath().resolve("TemplateForgedAlliance.exe"); @@ -141,15 +141,15 @@ public void testRun() throws Exception { List files = filesCaptor.getValue(); files.sort(Comparator.comparing(FeaturedModFile::getFileId)); - assertThat(files.get(0).getFileId(), is(1)); + assertThat(files.get(0).getFileId(), is((short) 1)); assertThat(files.get(0).getMd5(), is("47df959058cb52fe966ea5936dbd8f4c")); assertThat(files.get(0).getName(), is("ForgedAlliance.1337.exe")); - assertThat(files.get(0).getVersion(), is((short) 1337)); + assertThat(files.get(0).getVersion(), is(1337)); - assertThat(files.get(1).getFileId(), is(2)); + assertThat(files.get(1).getFileId(), is((short) 2)); assertThat(files.get(1).getMd5(), is(notNullValue())); assertThat(files.get(1).getName(), is("someDir.1337.nx3")); - assertThat(files.get(1).getVersion(), is((short) 1337)); + assertThat(files.get(1).getVersion(), is(1337)); assertThat(Files.exists(targetFolder.getRoot().toPath().resolve("updates_faf_files/someDir.1337.nx3")), is(true)); assertThat(Files.exists(targetFolder.getRoot().toPath().resolve("updates_faf_files/ForgedAlliance.1337.exe")), is(true));