openvidu-server: custom-layout path check fix

pull/255/head
pabloFuente 2019-03-20 14:54:17 +01:00
parent f205827fbe
commit 984fd13374
1 changed files with 26 additions and 11 deletions

View File

@ -653,23 +653,38 @@ public class RecordingManager {
// Property openvidu.recording.custom-layout changed // Property openvidu.recording.custom-layout changed
File dir = new File(openviduRecordingCustomLayout); File dir = new File(openviduRecordingCustomLayout);
if (dir.exists()) { if (dir.exists()) {
if (dir.listFiles() == null) { if (!dir.isDirectory()) {
String errorMessage = "The custom layouts path \"" + openviduRecordingCustomLayout String errorMessage = "The custom layouts path \"" + openviduRecordingCustomLayout
+ "\" is not valid. Reason: OpenVidu Server needs read permissions. Try running command \"sudo chmod 755 " + "\" is not valid. Reason: path already exists but it is not a directory";
+ openviduRecordingCustomLayout + "\"";
log.error(errorMessage); log.error(errorMessage);
throw new OpenViduException(Code.RECORDING_FILE_EMPTY_ERROR, errorMessage); throw new OpenViduException(Code.RECORDING_FILE_EMPTY_ERROR, errorMessage);
} else { } else {
log.info("OpenVidu Server has read permissions on custom layout path: {}", if (dir.listFiles() == null) {
openviduRecordingCustomLayout); String errorMessage = "The custom layouts path \"" + openviduRecordingCustomLayout
log.info("Custom layouts path successfully initialized at {}", openviduRecordingCustomLayout); + "\" is not valid. Reason: OpenVidu Server needs read permissions. Try running command \"sudo chmod 755 "
+ openviduRecordingCustomLayout + "\"";
log.error(errorMessage);
throw new OpenViduException(Code.RECORDING_FILE_EMPTY_ERROR, errorMessage);
} else {
log.info("OpenVidu Server has read permissions on custom layout path: {}",
openviduRecordingCustomLayout);
log.info("Custom layouts path successfully initialized at {}", openviduRecordingCustomLayout);
}
} }
} else { } else {
String errorMessage = "The custom layouts path \"" + openviduRecordingCustomLayout try {
+ "\" is not valid. Reason: OpenVidu Server cannot find path \"" + openviduRecordingCustomLayout Files.createDirectories(dir.toPath());
+ "\" and doesn't have permissions to create it"; log.warn(
log.error(errorMessage); "OpenVidu custom layouts path (system property 'openvidu.recording.custom-layout') has been created, being folder {}. "
throw new OpenViduException(Code.RECORDING_FILE_EMPTY_ERROR, errorMessage); + "It is an empty folder, so no custom layout is currently present",
dir.getAbsolutePath());
} catch (IOException e) {
String errorMessage = "The custom layouts path \"" + openviduRecordingCustomLayout
+ "\" is not valid. Reason: OpenVidu Server cannot find path \""
+ openviduRecordingCustomLayout + "\" and doesn't have permissions to create it";
log.error(errorMessage);
throw new OpenViduException(Code.RECORDING_FILE_EMPTY_ERROR, errorMessage);
}
} }
} }