diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java index 49271f97f2..c4dc636c99 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java @@ -176,8 +176,7 @@ private void confirmExactlyOneResult() { private void confirmValidDirectory() { Path vhd = getPath(); if (!Files.exists(vhd)) { - throw new IllegalStateException("Vitro home directory '" + vhd - + "' does not exist."); + createHomeDirectory(vhd); } if (!Files.isDirectory(vhd)) { throw new IllegalStateException("Vitro home directory '" + vhd @@ -241,6 +240,18 @@ public void populate() { } + /** + * Create home directory + */ + private static void createHomeDirectory(Path vhdDir) { + try { + vhdDir.toFile().mkdirs(); + } catch (Exception e) { + log.error(e, e); + throw new RuntimeException("Failed to create home directory " + vhdDir); + } + } + /** * Copy file from home source to home destination */