mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-04 15:09:28 +02:00
Double check directory creation
This commit is contained in:
@@ -471,8 +471,14 @@ public final class IOUtil
|
||||
{
|
||||
if (!directory.exists() &&!directory.mkdirs())
|
||||
{
|
||||
throw new IllegalStateException(
|
||||
"could not create directory ".concat(directory.getPath()));
|
||||
// Sometimes, the previous check simply has the wrong result (either the 'exists()' returnes false though the
|
||||
// directory exists or 'mkdirs()' returns false though the directory was created successfully.
|
||||
// We therefore have to double check here. Funny though, in these cases a second check with 'directory.exists()'
|
||||
// still returns false. As it seems, 'directory.getAbsoluteFile().exists()' creates a new object that fixes this
|
||||
// problem.
|
||||
if (!directory.getAbsoluteFile().exists()) {
|
||||
throw new IllegalStateException("could not create directory ".concat(directory.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user