mirror of https://github.com/Chocobozzz/PeerTube
Fix duplicate chapters error
parent
12ea8f0dd1
commit
eb02a5dd5d
|
@ -79,12 +79,18 @@ async function createChapters (options: {
|
||||||
}) {
|
}) {
|
||||||
const { chapters, transaction, videoId } = options
|
const { chapters, transaction, videoId } = options
|
||||||
|
|
||||||
|
const existingTimecodes = new Set<number>()
|
||||||
|
|
||||||
for (const chapter of chapters) {
|
for (const chapter of chapters) {
|
||||||
|
if (existingTimecodes.has(chapter.timecode)) continue
|
||||||
|
|
||||||
await VideoChapterModel.create({
|
await VideoChapterModel.create({
|
||||||
title: chapter.title,
|
title: chapter.title,
|
||||||
timecode: chapter.timecode,
|
timecode: chapter.timecode,
|
||||||
videoId
|
videoId
|
||||||
}, { transaction })
|
}, { transaction })
|
||||||
|
|
||||||
|
existingTimecodes.add(chapter.timecode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue