Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,15 @@ private static class TempDirHolder {

private static String initializeTempDir() {
try {
String tempDirParent = CommonsPropertiesUtil.getApplicationTempDirParent();
if (tempDirParent != null) {
ensureDirectoryExists(new File(tempDirParent));
}

String tempDirName = CommonsPropertiesUtil.getApplicationTempDirName();

File dir = File.createTempFile(tempDirName, "");
File dir = File.createTempFile(tempDirName, "",
tempDirParent == null ? null : new File(tempDirParent));
File temp = new File(dir.getParentFile(), tempDirName);

if (!dir.delete()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.codeforces.commons.properties.internal;

import com.codeforces.commons.properties.PropertiesUtil;
import com.codeforces.commons.text.StringUtil;

import java.io.File;
import java.util.List;

import javax.annotation.Nullable;

/**
* @author Mike Mirzayanov
* @author Maxim Shipko (sladethe@gmail.com)
Expand All @@ -30,6 +34,11 @@ public static String getApplicationTempDirName() {
return PropertyValuesHolder.TEMP_DIR_NAME;
}

@Nullable
public static String getApplicationTempDirParent() {
return PropertyValuesHolder.TEMP_DIR_PARENT;
}

public static List<String> getSecurePasswords() {
return PropertyValuesHolder.SECURE_PASSWORDS;
}
Expand All @@ -52,6 +61,8 @@ public static String getSubscriptionToken() {

private static final class PropertyValuesHolder {
private static final String TEMP_DIR_NAME = getProperty("temp-dir.name", "temp");
@Nullable
private static final String TEMP_DIR_PARENT = StringUtil.trimToNull(getProperty("temp-dir.parent", null));
private static final List<String> SECURE_PASSWORDS = getListProperty("security.secure-passwords", "");
private static final List<String> SECURE_HOSTS = getListProperty("security.secure-hosts", "");
private static final boolean BYPASS_CERTIFICATE_CHECK
Expand Down