When writing temporary plugin files, ensure the directory exists
When adding plugins as streams in PluginIT (which upcoming commits will do), installing the plugin failed, as the temporary directory does not exist. Instead of fixing the caller of `asTemp` to create the directory before the call, we instead change `asTemp` itself to create the directory, and can thereby simplify other callers, which also manually create the directory. Change-Id: If7962ee2898f52c0db43cf030528a82530a2442b
This commit is contained in:
@@ -110,9 +110,6 @@ public class JarPluginProvider implements ServerPluginProvider {
|
||||
|
||||
public static Path storeInTemp(String pluginName, InputStream in, SitePaths sitePaths)
|
||||
throws IOException {
|
||||
if (!Files.exists(sitePaths.tmp_dir)) {
|
||||
Files.createDirectories(sitePaths.tmp_dir);
|
||||
}
|
||||
return PluginUtil.asTemp(in, tempNameFor(pluginName), ".jar", sitePaths.tmp_dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public class PluginUtil {
|
||||
}
|
||||
|
||||
static Path asTemp(InputStream in, String prefix, String suffix, Path dir) throws IOException {
|
||||
Files.createDirectories(dir);
|
||||
Path tmp = Files.createTempFile(dir, prefix, suffix);
|
||||
boolean keep = false;
|
||||
try (OutputStream out = Files.newOutputStream(tmp)) {
|
||||
|
||||
Reference in New Issue
Block a user