Skip to content

Commit

Permalink
Merge branch 'release/0.10.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Nov 18, 2017
2 parents 2d25e8a + 4f121c1 commit aaae4d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.mp3 binary
*.zip binary
*.exe binary
*.jar binary
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ apply plugin: 'propdeps'
apply plugin: 'idea'

group = 'faforever'
version = '0.10.1'
version = '0.10.2'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.faforever.api.deployment.git.GitWrapper;
import com.faforever.api.featuredmods.FeaturedModFile;
import com.faforever.api.featuredmods.FeaturedModService;
import com.faforever.api.utils.FilePermissionUtil;
import com.faforever.commons.fa.ForgedAllianceExePatcher;
import com.faforever.commons.mod.ModReader;
import com.google.common.io.ByteStreams;
Expand Down Expand Up @@ -108,7 +109,7 @@ public void run() {
log.warn("Could not find any files to deploy. Is the configuration correct?");
return;
}
files.forEach(this::renameToFinalFile);
files.forEach(this::finalizeFile);

updateDatabase(files, version, modName);

Expand Down Expand Up @@ -161,7 +162,7 @@ private void updateDatabase(List<StagedFile> files, short version, String modNam
List<FeaturedModFile> featuredModFiles = files.stream()
.map(file -> new FeaturedModFile()
.setMd5(noCatch(() -> hash(file.getTargetFile().toFile(), md5())).toString())
.setFileId((short) file.getFileId())
.setFileId(file.getFileId())
.setName(file.getTargetFile().getFileName().toString())
.setVersion(version)
)
Expand Down Expand Up @@ -195,12 +196,16 @@ private List<StagedFile> packageDirectories(Path repositoryDirectory, short vers

/**
* Renames the temporary file to the target file so the file is only available under its final name when it is
* complete.
* complete, and makes the file readable for everyone.
*/
private StagedFile renameToFinalFile(StagedFile file) {
private StagedFile finalizeFile(StagedFile file) {
Path source = file.getTmpFile();
Path target = file.getTargetFile();
log.trace("Renaming '{}' to '{}", source, target);

log.trace("Setting default file permission of '{}'", source);
FilePermissionUtil.setDefaultFilePermission(source);

log.trace("Renaming '{}' to '{}'", source, target);
noCatch(() -> Files.move(source, target, StandardCopyOption.ATOMIC_MOVE));
return file;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/faforever/api/utils/FilePermissionUtil.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.faforever.api.utils;


import java.io.IOException;
import lombok.SneakyThrows;

import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -16,7 +17,8 @@ private FilePermissionUtil() {
// Utility class
}

public static void setDefaultFilePermission(Path path) throws IOException {
@SneakyThrows
public static void setDefaultFilePermission(Path path) {
if (!FileSystems.getDefault().supportedFileAttributeViews().contains(FILE_PERMISSION_POSIX)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ faf-api:
error-redirect-url-format: ${STEAM_LINK_ERROR_URL:http://localhost:8020/error?code=%s}
spring:
datasource:
url: jdbc:mysql://${DATABASE_ADDRESS:localhost}/${DATABASE_NAME:faf}?useSSL=false
url: jdbc:mysql://${DATABASE_ADDRESS:127.0.0.1}/${DATABASE_NAME:faf}?useSSL=false
name: faf
username: ${DATABASE_USERNAME:faf-java-api}
password: ${DATABASE_PASSWORD:banana}
Expand Down

0 comments on commit aaae4d0

Please sign in to comment.