mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-09-20 01:47:21 +03:00
Fix duplicate chapters error
This commit is contained in:
parent
12ea8f0dd1
commit
eb02a5dd5d
@ -79,12 +79,18 @@ async function createChapters (options: {
|
||||
}) {
|
||||
const { chapters, transaction, videoId } = options
|
||||
|
||||
const existingTimecodes = new Set<number>()
|
||||
|
||||
for (const chapter of chapters) {
|
||||
if (existingTimecodes.has(chapter.timecode)) continue
|
||||
|
||||
await VideoChapterModel.create({
|
||||
title: chapter.title,
|
||||
timecode: chapter.timecode,
|
||||
videoId
|
||||
}, { transaction })
|
||||
|
||||
existingTimecodes.add(chapter.timecode)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user