diff --git a/Server/src/routes/api/sermons.js b/Server/src/routes/api/sermons.js index 505bb1a..961e28f 100644 --- a/Server/src/routes/api/sermons.js +++ b/Server/src/routes/api/sermons.js @@ -109,7 +109,14 @@ router.post("/a/", function(req,res){ res.status(404).json({"status":404,"message":"Sermon does not exist"}); return; } - res.status(201).json({"status":201,"sermon":sermon}); + renameFile(req.body.tmpPath,req.body.finalPath,function(err){ + if (err){ + removeFile(req.body.tmpPath); + res.status(500).json({"status":500,"message":"Could not rename the temp file"}); + } else { + res.status(201).json({"status":201,"sermon":sermon}); + } + }); /////****************************** /////Add the sermon to the postgres db for the existing site // var pg = require("../database/postgres-for-old-db/addSermon");