fix detection of temporary folder

This commit is contained in:
Bixilon 2020-12-02 21:39:56 +01:00
parent 9ca097ccae
commit f7e0beb537
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 2 additions and 3 deletions

View File

@ -27,6 +27,7 @@ public class StaticConfiguration {
public static boolean LOG_RELATIVE_TIME = false; // prefix all log messages with the relative start time in milliseconds instead of the formatted time
public static boolean VERBOSE_ENTITY_META_DATA_LOGGING = false; // if true, the entity meta data is getting serialized
public static String HOME_DIRECTORY;
public static final String TEMPORARY_FOLDER = System.getProperty("java.io.tmpdir", HOME_DIRECTORY + "/tmp/") + "/";
static {
// Sets Config.homeDir to the correct folder per OS

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.data.assets;
import com.google.common.base.StandardSystemProperty;
import com.google.errorprone.annotations.DoNotCall;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
@ -258,8 +257,7 @@ public class AssetsManager {
private static String saveAsset(InputStream data) throws IOException {
File tempDestinationFile = null;
while (tempDestinationFile == null || tempDestinationFile.exists()) { // file exist? lol
//noinspection ConstantConditions
tempDestinationFile = new File(System.getProperty(StandardSystemProperty.JAVA_IO_TMPDIR.value()) + "/minosoft/" + Util.generateRandomString(32));
tempDestinationFile = new File(StaticConfiguration.TEMPORARY_FOLDER + "minosoft/" + Util.generateRandomString(32));
}
Util.createParentFolderIfNotExist(tempDestinationFile);