Skip to content

Commit

Permalink
Check if the URL exists before sending it
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Jun 2, 2024
1 parent 410adbf commit 1212cdd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/faforever/client/mod/ModUploadTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

Expand Down Expand Up @@ -77,7 +78,12 @@ protected Void call() throws Exception {
log.debug("Uploading mod `{}` as `{}`", modPath, tmpFile);
updateTitle(i18n.get("modVault.upload.uploading"));

return fafApiAccessor.uploadFile("/mods/upload", tmpFile, byteListener, Map.of("metadata", Map.of("repositoryUrl", repositoryURL))).block();
HashMap<String, String> parameters = new HashMap<>();
if (repositoryURL != null) {
parameters.put("repositoryUrl", repositoryURL.toString());
}

return fafApiAccessor.uploadFile("/mods/upload", tmpFile, byteListener, Map.of("metadata", parameters)).block();
} finally {
Files.delete(tmpFile);
ResourceLocks.freeUploadLock();
Expand Down

0 comments on commit 1212cdd

Please sign in to comment.