Skip to content

Commit

Permalink
fix: log uploader failing incorrectly, updated agent and versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Dec 6, 2024
1 parent 7c6c488 commit ed2745f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
13 changes: 8 additions & 5 deletions subprocess/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ java {

group = "net.creeperhost"
archivesBaseName = "launcher"

def details = versionDetails()
def branch = System.getenv("BRANCH_OVERRIDE") ?: System.getenv("GITHUB_BRANCH") ?: "release" //(details.branchName ?: System.getenv("GITHUB_BRANCH") ?: "release").replaceAll('/', '-')
version = System.getenv("VERSION_OVERRIDE") ?: (details.gitHash + (branch != 'release' ? "-" + branch : ""))
def sentryDsn = System.getenv("SUBPROCESS_SENTRY_DSN") ?: ""
def branch = System.getenv("GITHUB_BRANCH") ?: "release"

def packageJson = new JsonSlurper().parse(file("../package.json"))
def appVersion = packageJson.version
assert appVersion != null && appVersion != "", "package.json must have a version field"

version = appVersion + "+${details.gitHash}-${branch}"

repositories {
mavenLocal()
Expand Down Expand Up @@ -96,7 +99,7 @@ test {
tasks.register('processSource', Sync) {
from sourceSets.main.java
inputs.property 'version', version
filter(ReplaceTokens, tokens: [APPVERSION: version, WEBVERSION: version, SHAREDVERSION: packageJson.version, BRANCH: branch, SENTRY: sentryDsn])
filter(ReplaceTokens, tokens: [APPVERSION: version, BRANCH: branch, COMMIT: details.gitHash])
into "$buildDir/src"
}

Expand Down Expand Up @@ -198,7 +201,7 @@ def writeVersion = tasks.register('writeVersion') {
def fileData = file("./meta-template.json").text
def template = new JsonSlurper().parseText(fileData)

template.appVersion = packageJson.version
template.appVersion = version
template.commit = details.gitHash
template.branch = branch
template.released = Instant.now().getEpochSecond()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ public class Constants {
public static final int WEBSOCKET_PORT = 13377;
public static final String APPVERSION = "@APPVERSION@";
public static final String BRANCH = "@BRANCH@";
public static final String SHARED_VERSION = "@SHAREDVERSION@";
public static final String SENTRY_DSN = "@SENTRY@";
public static final String COMMIT = "@COMMIT@";
public static final String PLATFORM = WORKING_DIR.toAbsolutePath().toString().contains("Overwolf") ? "Overwolf" : "Electron";

public static final String USER_AGENT = "modpacklauncher/" + APPVERSION + " Mozilla/5.0 (" + OS.CURRENT.name() + ") AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.138 Safari/537.36 Vivaldi/1.8.770.56";
public static final String USER_AGENT = "ftb-app/" + APPVERSION + " OS/"+ OS.CURRENT.name() + " Platform/" + PLATFORM + " Branch/" + BRANCH + " Commit/" + COMMIT;
private static final Throttler GLOBAL_THROTTLER = new Throttler();

public static final String WEBSOCKET_SECRET = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static String uploadUILogs() {
var appDetails = new JsonObject();
appDetails.addProperty("app", Constants.APPVERSION);
appDetails.addProperty("platform", Constants.PLATFORM);
appDetails.addProperty("sharedVersion", Constants.SHARED_VERSION);
appDetails.addProperty("sharedVersion", Constants.APPVERSION);
obj.add("appDetails", appDetails);

var systemDetails = new JsonObject();
Expand All @@ -91,8 +91,13 @@ public static String uploadUILogs() {

// Collect all the instance logs
obj.add("instanceLogs", collectInstanceLogs());

String uploadResult = uploadPaste(GSON.toJson(obj));
if (uploadResult == null || uploadResult.equals("failed to upload")) {
return null;
}

return uploadPaste(GSON.toJson(obj));
return uploadResult;
}

private static String getFilteredSettings() {
Expand Down

0 comments on commit ed2745f

Please sign in to comment.