fix a header sending error, sent twice

This commit is contained in:
Luke Berndt
2024-09-13 22:26:19 -04:00
parent 3117750b10
commit 6098e679f0

View File

@@ -14,6 +14,7 @@ var fs = require('fs');
const { PutObjectCommand, S3Client } = require("@aws-sdk/client-s3"); const { PutObjectCommand, S3Client } = require("@aws-sdk/client-s3");
const { fromIni } = require("@aws-sdk/credential-providers"); const { fromIni } = require("@aws-sdk/credential-providers");
const e = require('express');
var s3_endpoint = process.env['S3_ENDPOINT'] != null ? process.env['S3_ENDPOINT'] : 'https://s3.us-west-1.wasabisys.com'; var s3_endpoint = process.env['S3_ENDPOINT'] != null ? process.env['S3_ENDPOINT'] : 'https://s3.us-west-1.wasabisys.com';
var s3_region = process.env['S3_REGION'] != null ? process.env['S3_REGION'] : 'us-west-1'; var s3_region = process.env['S3_REGION'] != null ? process.env['S3_REGION'] : 'us-west-1';
@@ -177,6 +178,7 @@ const createPodcast = async (tmpEventFolder, podcastFile, event) => {
inputs.forEach((value, i) => { inputs.forEach((value, i) => {
concat = concat + "file '" + value + "'\n"; concat = concat + "file '" + value + "'\n";
}); });
try {
const concatFile = tmpEventFolder + "/FILES.txt" const concatFile = tmpEventFolder + "/FILES.txt"
fs.writeFileSync(concatFile, concat, "utf8"); fs.writeFileSync(concatFile, concat, "utf8");
// https://video.stackexchange.com/questions/21315/concatenating-split-media-files-using-concat-protocol // https://video.stackexchange.com/questions/21315/concatenating-split-media-files-using-concat-protocol
@@ -214,6 +216,9 @@ const createPodcast = async (tmpEventFolder, podcastFile, event) => {
command.push(podcastFile) command.push(podcastFile)
//console.log("Running command: " + command); //console.log("Running command: " + command);
await ffmpeg(command); await ffmpeg(command);
} catch (e) {
console.error("Error creating podcast " + e);
}
} }
const cleanupEvent = (folder, filename) => { const cleanupEvent = (folder, filename) => {
@@ -382,11 +387,12 @@ exports.addNewEvent = async function (req, res, next) {
const savedEvent = await event.save(); const savedEvent = await event.save();
//console.log("Event ID " + savedEvent._id); //console.log("Event ID " + savedEvent._id);
const url = "/events/" + event._id; const url = "/events/" + event._id;
res.contentType('json');
res.send(JSON.stringify({ url: url }));
await packageEvent(savedEvent._id); await packageEvent(savedEvent._id);
res.contentType('json');
res.send(JSON.stringify({ url: url }));
} }
catch (err) { catch (err) {
console.error("Error creating event" + err); console.error("Error creating event" + err);