diff options
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 89ca0265008..49678c5e385 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -841,15 +841,24 @@ public class SessionRepository { File schemasDir = applicationDir.resolve(ApplicationPackage.SCHEMAS_DIR.getRelative()).toFile(); File sdDir = applicationDir.resolve(ApplicationPackage.SEARCH_DEFINITIONS_DIR.getRelative()).toFile(); if (sdDir.exists() && sdDir.isDirectory()) { - File[] sdFiles = sdDir.listFiles(); - if (sdFiles != null) { - Files.createDirectories(schemasDir.toPath()); - Arrays.asList(sdFiles).forEach(file -> Exceptions.uncheck( - () -> Files.move(file.toPath(), - schemasDir.toPath().resolve(file.toPath().getFileName()), - StandardCopyOption.REPLACE_EXISTING))); + try { + File[] sdFiles = sdDir.listFiles(); + if (sdFiles != null) { + Files.createDirectories(schemasDir.toPath()); + Arrays.asList(sdFiles).forEach(file -> Exceptions.uncheck( + () -> Files.move(file.toPath(), + schemasDir.toPath().resolve(file.toPath().getFileName()), + StandardCopyOption.REPLACE_EXISTING))); + } + Files.delete(sdDir.toPath()); + } catch (IOException | UncheckedIOException e) { + if (schemasDir.exists() && schemasDir.isDirectory()) + throw new InvalidApplicationException( + "Both " + ApplicationPackage.SCHEMAS_DIR.getRelative() + " and " + ApplicationPackage.SEARCH_DEFINITIONS_DIR + + " exists in application package, please remove " + ApplicationPackage.SEARCH_DEFINITIONS_DIR, e); + else + throw e; } - Files.delete(sdDir.toPath()); } } |