Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving temp directory creation #5452

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -24,6 +24,8 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -375,14 +377,8 @@ public void deconfigure(WebAppContext context) throws Exception
@Override
public void cloneConfigure(WebAppContext template, WebAppContext context) throws Exception
{
File tmpDir = File.createTempFile(WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context), "", template.getTempDirectory().getParentFile());
if (tmpDir.exists())
{
IO.delete(tmpDir);
}
tmpDir.mkdir();
tmpDir.deleteOnExit();
context.setTempDirectory(tmpDir);
Path tmpDir = Files.createTempDirectory(template.getTempDirectory().getParentFile().toPath(), WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context));
context.setTempDirectory(tmpDir.toFile());
}

/**
Expand Down Expand Up @@ -510,11 +506,7 @@ public void makeTempDirectory(File parent, WebAppContext context)
else
{
//ensure file will always be unique by appending random digits
tmpDir = File.createTempFile(temp, ".dir", parent);
//delete the file that was created
tmpDir.delete();
//and make a directory of the same name
tmpDir.mkdirs();
tmpDir = Files.createTempDirectory(parent.toPath(), temp).toFile();
}
configureTempDirectory(tmpDir, context);

Expand Down