Skip to content

Commit 39dcff7

Browse files
committed
Silently attempt precise linux OS
1 parent bc4c4a3 commit 39dcff7

File tree

2 files changed

+19
-206
lines changed

2 files changed

+19
-206
lines changed

json-data-utils/src/main/java/net/minecraftforge/util/data/DownloadUtils.java

Lines changed: 0 additions & 190 deletions
This file was deleted.

json-data-utils/src/main/java/net/minecraftforge/util/data/OS.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package net.minecraftforge.util.data;
66

7+
import net.minecraftforge.util.logging.SimpleLogger;
78
import org.jetbrains.annotations.Nullable;
89

910
import java.io.IOException;
@@ -62,6 +63,7 @@ public String key() {
6263
if (value.key.equals(key))
6364
return value;
6465
}
66+
6567
return null;
6668
}
6769

@@ -78,23 +80,24 @@ private static OS getCurrent() {
7880
String prop = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
7981
for (OS os : $values) {
8082
for (String key : os.names) {
81-
if (prop.contains(key)) {
82-
if (os == LINUX) {
83-
try {
84-
for (String line : Files.readAllLines(Paths.get("/etc/os-release"), StandardCharsets.UTF_8)) {
85-
line = line.toLowerCase(Locale.ENGLISH);
86-
if (line.startsWith("name=") && line.contains("alpine")) {
87-
return ALPINE;
88-
}
89-
}
90-
} catch (IOException ignored) {
91-
// TODO log that we can't read /etc/os-release
92-
}
93-
}
94-
return os;
95-
}
83+
if (!prop.contains(key)) continue;
84+
85+
return os == LINUX ? getCurrentLinux() : os;
9686
}
9787
}
9888
return UNKNOWN;
9989
}
100-
}
90+
91+
private static OS getCurrentLinux() {
92+
try {
93+
for (String line : Files.readAllLines(Paths.get("/etc/os-release"), StandardCharsets.UTF_8)) {
94+
line = line.toLowerCase(Locale.ENGLISH);
95+
if (line.startsWith("name=") && line.contains("alpine")) {
96+
return ALPINE;
97+
}
98+
}
99+
} catch (IOException ignored) { }
100+
101+
return LINUX;
102+
}
103+
}

0 commit comments

Comments
 (0)