aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-02 15:32:53 +0200
committerChocobozzz <me@florianbigard.com>2023-06-29 10:16:57 +0200
commit318aa9c42250c38c845f007a83ee84a0884436c1 (patch)
tree199f4057a3665f0037f42f780f0eff23c7699245 /server
parent9c5cc501335b9f7dba4aa492b8fda68d4881d28d (diff)
downloadPeerTube-318aa9c42250c38c845f007a83ee84a0884436c1.tar.gz
PeerTube-318aa9c42250c38c845f007a83ee84a0884436c1.tar.zst
PeerTube-318aa9c42250c38c845f007a83ee84a0884436c1.zip
Delete storyboard file on video deletion
Diffstat (limited to 'server')
-rw-r--r--server/models/video/video.ts3
-rw-r--r--server/tests/api/videos/video-storyboard.ts27
2 files changed, 28 insertions, 2 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 0e9a84426..fd56d2423 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -762,7 +762,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
762 name: 'videoId', 762 name: 'videoId',
763 allowNull: false 763 allowNull: false
764 }, 764 },
765 onDelete: 'cascade' 765 onDelete: 'cascade',
766 hooks: true
766 }) 767 })
767 Storyboard: StoryboardModel 768 Storyboard: StoryboardModel
768 769
diff --git a/server/tests/api/videos/video-storyboard.ts b/server/tests/api/videos/video-storyboard.ts
index 7ccdca8f7..5fde6ce45 100644
--- a/server/tests/api/videos/video-storyboard.ts
+++ b/server/tests/api/videos/video-storyboard.ts
@@ -1,6 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { readdir } from 'fs-extra'
5import { basename } from 'path'
4import { FIXTURE_URLS } from '@server/tests/shared' 6import { FIXTURE_URLS } from '@server/tests/shared'
5import { areHttpImportTestsDisabled } from '@shared/core-utils' 7import { areHttpImportTestsDisabled } from '@shared/core-utils'
6import { HttpStatusCode, VideoPrivacy } from '@shared/models' 8import { HttpStatusCode, VideoPrivacy } from '@shared/models'
@@ -48,6 +50,8 @@ async function checkStoryboard (options: {
48describe('Test video storyboard', function () { 50describe('Test video storyboard', function () {
49 let servers: PeerTubeServer[] 51 let servers: PeerTubeServer[]
50 52
53 let baseUUID: string
54
51 before(async function () { 55 before(async function () {
52 this.timeout(120000) 56 this.timeout(120000)
53 57
@@ -63,6 +67,7 @@ describe('Test video storyboard', function () {
63 67
64 // 5s video 68 // 5s video
65 const { uuid } = await servers[0].videos.quickUpload({ name: 'upload', fixture: 'video_short.webm' }) 69 const { uuid } = await servers[0].videos.quickUpload({ name: 'upload', fixture: 'video_short.webm' })
70 baseUUID = uuid
66 await waitJobs(servers) 71 await waitJobs(servers)
67 72
68 for (const server of servers) { 73 for (const server of servers) {
@@ -173,9 +178,29 @@ describe('Test video storyboard', function () {
173 } 178 }
174 }) 179 })
175 180
176 it('Should generate a storyboard with different video durations', async function () { 181 it('Should cleanup storyboards on video deletion', async function () {
177 this.timeout(60000) 182 this.timeout(60000)
178 183
184 const { storyboards } = await servers[0].storyboard.list({ id: baseUUID })
185 const storyboardName = basename(storyboards[0].storyboardPath)
186
187 const listFiles = () => {
188 const storyboardPath = servers[0].getDirectoryPath('storyboards')
189 return readdir(storyboardPath)
190 }
191
192 {
193 const storyboads = await listFiles()
194 expect(storyboads).to.include(storyboardName)
195 }
196
197 await servers[0].videos.remove({ id: baseUUID })
198 await waitJobs(servers)
199
200 {
201 const storyboads = await listFiles()
202 expect(storyboads).to.not.include(storyboardName)
203 }
179 }) 204 })
180 205
181 after(async function () { 206 after(async function () {