Skip to content

Commit

Permalink
add back check for if dir already exists
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917583 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed May 8, 2024
1 parent c960ee6 commit efce9ba
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,23 @@ private void createPOIFilesDirectory() throws IOException {
// Create our temp dir only once by double-checked locking
// The directory is not deleted, even if it was created by this TempFileCreationStrategy
if (dir == null) {
final String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
if (tmpDir == null) {
throw new IOException("System's temporary directory not defined - set the -D" + JAVA_IO_TMPDIR + " jvm property!");
}
dirLock.lock();
try {
if (dir == null) {
String tmpDir = System.getProperty(JAVA_IO_TMPDIR);
if (tmpDir == null) {
throw new IOException("System's temporary directory not defined - set the -D" + JAVA_IO_TMPDIR + " jvm property!");
}
Path dirPath = Paths.get(tmpDir, POIFILES);
dir = Files.createDirectories(dirPath).toFile();
File fileDir = dirPath.toFile();
if (fileDir.exists()) {
if (!fileDir.isDirectory()) {
throw new IOException("Could not create temporary directory. '" + fileDir + "' exists but is not a directory.");
}
dir = fileDir;
} else {
dir = Files.createDirectories(dirPath).toFile();
}
}
} finally {
dirLock.unlock();
Expand Down

0 comments on commit efce9ba

Please sign in to comment.