Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]).then(() => {
if (req.fragmentList === null) {
let movie = VideoLib.MovieParser.parse(req.file);
req.fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
}
next();
}).finally(() => {
return Promise.all([req.file, req.index].map((file) => {
static index(name) {
let fileName = path.join(config.mediaPath, name);
let indexName = Indexer.getIndexName(name);
let tmpName = Indexer.getTempName(name);
let file = null;
let index = null;
try {
file = fs.openSync(fileName, 'r');
index = fs.openSync(tmpName, 'w');
let movie = VideoLib.MovieParser.parse(file);
let fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
VideoLib.FragmentListIndexer.index(fragmentList, index);
} finally {
if (file !== null) {
fs.closeSync(file);
}
if (index !== null) {
fs.closeSync(index);
}
}
if (fs.existsSync(tmpName)) {
try {
Indexer.makeDirs(path.dirname(indexName));
fs.renameSync(tmpName, indexName);
} catch (ex) {
fs.unlinkSync(tmpName);