[TEST] delete the temp folder if already existing (this time for real)

Original commit: elastic/x-pack-elasticsearch@618fcd4dbd
This commit is contained in:
javanna 2014-11-28 10:11:38 +01:00 committed by Luca Cavanna
parent 8c1fcb52ea
commit ac2b30f150
1 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.google.common.base.Charsets;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.client.support.Headers;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.os.OsUtils;
import org.elasticsearch.common.settings.ImmutableSettings;
@ -151,8 +152,9 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
private static File createFolder(File parent, String name) {
File createdFolder = new File(parent, name);
//the directory might exist e.g. if the global cluster gets restarted, then we recreate the directory as well
if (createdFolder.exists()) {
if (!createdFolder.delete()) {
if (!FileSystemUtils.deleteRecursively(createdFolder)) {
throw new RuntimeException("Could not delete existing temporary folder: " + createdFolder.getAbsolutePath());
}
}