"private": true,
"licence": "GPLv3",
"author": {
- "name": "Florian Bigard",
- "email": "me@florianbigard.com",
+ "name": "Chocobozzz",
+ "email": "chocobozzz@cpy.re",
"url": "http://github.com/Chocobozzz"
},
"repository": {
"peertube": "dist/server/tools/peertube.js"
},
"author": {
- "name": "Florian Bigard",
- "email": "florian.bigard@gmail.com",
+ "name": "Chocobozzz",
+ "email": "chocobozzz@cpy.re",
"url": "http://github.com/Chocobozzz"
},
"repository": {
import {
- AfterDestroy,
AllowNull,
+ BeforeDestroy,
BelongsTo,
Column,
CreatedAt,
})
Actor: ActorModel
- @AfterDestroy
- static removeFile (instance: VideoRedundancyModel) {
+ @BeforeDestroy
+ static async removeFile (instance: VideoRedundancyModel) {
// Not us
if (!instance.strategy) return
- logger.info('Removing duplicated video file %s-%s.', instance.VideoFile.Video.uuid, instance.VideoFile.resolution)
+ const videoFile = await VideoFileModel.loadWithVideo(instance.videoFileId)
- return instance.VideoFile.Video.removeFile(instance.VideoFile)
+ logger.info('Removing duplicated video file %s-%s.', videoFile.Video.uuid, videoFile.resolution)
+
+ return videoFile.Video.removeFile(videoFile)
}
static async loadLocalByFileId (videoFileId: number) {
})
}
+ static loadWithVideo (id: number) {
+ const options = {
+ include: [
+ {
+ model: VideoModel.unscoped(),
+ required: true
+ }
+ ]
+ }
+
+ return VideoFileModel.findById(id, options)
+ }
+
hasSameUniqueKeysThan (other: VideoFileModel) {
return this.fps === other.fps &&
this.resolution === other.resolution &&
uploadVideo,
viewVideo,
wait,
- waitUntilLog
+ waitUntilLog,
+ checkVideoFilesWereRemoved, removeVideo
} from '../../utils'
import { waitJobs } from '../../utils/server/jobs'
import * as magnetUtil from 'magnet-uri'
await wait(5000)
await check1WebSeed(strategy)
+
+ await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ])
})
after(function () {
await wait(5000)
await check1WebSeed(strategy)
+
+ await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ])
})
after(function () {
await checkStatsWith2Webseed(strategy)
})
+ it('Should remove the video and the redundancy files', async function () {
+ this.timeout(20000)
+
+ await removeVideo(servers[1].url, servers[1].accessToken, video1Server2UUID)
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ await checkVideoFilesWereRemoved(video1Server2UUID, server.serverNumber)
+ }
+ })
+
after(function () {
return cleanServers()
})
.expect(expectedStatus)
}
-async function checkVideoFilesWereRemoved (videoUUID: string, serverNumber: number) {
+async function checkVideoFilesWereRemoved (
+ videoUUID: string,
+ serverNumber: number,
+ directories = [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]
+) {
const testDirectory = 'test' + serverNumber
- for (const directory of [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]) {
+ for (const directory of directories) {
const directoryPath = join(root(), testDirectory, directory)
const directoryExists = existsSync(directoryPath)