Skip to content

Commit

Permalink
Make sure directory exists before attempting to write to it (#7090)
Browse files Browse the repository at this point in the history
Summary:
Closes #7053

Pull Request resolved: #7090

Reviewed By: riversand963

Differential Revision: D22481199

Pulled By: pdillinger

fbshipit-source-id: 287477db94d57b18bee58189135f44936f1c3ca3
  • Loading branch information
adamretter authored and facebook-github-bot committed Jul 10, 2020
1 parent 4924a50 commit 1a8ca66
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion java/src/main/java/org/rocksdb/NativeLibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ File loadLibraryFromJarToTemp(final String tmpDir)
if (tmpDir == null || tmpDir.isEmpty()) {
temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
} else {
temp = new File(tmpDir, jniLibraryFileName);
final File parentDir = new File(tmpDir);
if (!parentDir.exists()) {
throw new RuntimeException(
"Directory: " + parentDir.getAbsolutePath() + " does not exist!");
}
temp = new File(parentDir, jniLibraryFileName);
if (temp.exists() && !temp.delete()) {
throw new RuntimeException("File: " + temp.getAbsolutePath()
+ " already exists and cannot be removed.");
Expand Down

0 comments on commit 1a8ca66

Please sign in to comment.