Fix bug, which caused the HLS servlet to double up the recordings path

This commit is contained in:
0xb00bface 2020-12-05 23:21:06 +01:00
parent 5135e10c19
commit d76ee3994b
1 changed files with 2 additions and 3 deletions

View File

@ -50,7 +50,8 @@ public class HlsServlet extends AbstractCtbrecServlet {
boolean idOnly = request.indexOf('/') < 0; boolean idOnly = request.indexOf('/') < 0;
if (idOnly) { if (idOnly) {
requestFile = rec.get().getPostProcessedFile(); requestFile = rec.get().getPostProcessedFile();
requestedFilePath = requestFile.getCanonicalPath(); serveSegment(req, resp, requestFile);
return;
} else { } else {
requestedFilePath = request.substring(request.indexOf('/')); requestedFilePath = request.substring(request.indexOf('/'));
requestFile = new File(requestedFilePath); requestFile = new File(requestedFilePath);
@ -73,7 +74,6 @@ public class HlsServlet extends AbstractCtbrecServlet {
} }
} catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e1) { } catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e1) {
writeResponse(resp, SC_UNAUTHORIZED, "{\"status\": \"error\", \"msg\": \"Authentication failed\"}"); writeResponse(resp, SC_UNAUTHORIZED, "{\"status\": \"error\", \"msg\": \"Authentication failed\"}");
return;
} }
} }
@ -99,7 +99,6 @@ public class HlsServlet extends AbstractCtbrecServlet {
private void serveSegment(HttpServletRequest req, HttpServletResponse resp, File requestedFile) throws IOException { private void serveSegment(HttpServletRequest req, HttpServletResponse resp, File requestedFile) throws IOException {
MimetypesFileTypeMap map = new MimetypesFileTypeMap(); MimetypesFileTypeMap map = new MimetypesFileTypeMap();
//String mimetype = requestedFile.getName().endsWith(".mp4") ? "video/mp4" : "application/octet-stream";
String mimetype = map.getContentType(requestedFile); String mimetype = map.getContentType(requestedFile);
LOG.debug("Serving {} as {}", requestedFile.getName(), mimetype); LOG.debug("Serving {} as {}", requestedFile.getName(), mimetype);
serveFile(req, resp, requestedFile, mimetype); serveFile(req, resp, requestedFile, mimetype);