aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/create-import-video-file-job.ts2
-rwxr-xr-xscripts/create-transcoding-job.ts2
-rwxr-xr-xscripts/prune-storage.ts110
-rw-r--r--server/controllers/lazy-static.ts7
-rw-r--r--server/lib/files-cache/videos-preview-cache.ts2
-rw-r--r--server/models/video/thumbnail.ts10
-rw-r--r--server/models/video/video.ts23
-rw-r--r--server/tests/cli/index.ts1
-rw-r--r--server/tests/cli/prune-storage.ts199
-rw-r--r--shared/extra-utils/miscs/miscs.ts5
-rw-r--r--shared/extra-utils/videos/videos.ts6
11 files changed, 323 insertions, 44 deletions
diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts
index c8c6c6429..2b636014a 100644
--- a/scripts/create-import-video-file-job.ts
+++ b/scripts/create-import-video-file-job.ts
@@ -25,7 +25,7 @@ run()
25async function run () { 25async function run () {
26 await initDatabaseModels(true) 26 await initDatabaseModels(true)
27 27
28 const video = await VideoModel.loadByUUIDWithFile(program['video']) 28 const video = await VideoModel.loadByUUID(program['video'])
29 if (!video) throw new Error('Video not found.') 29 if (!video) throw new Error('Video not found.')
30 if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') 30 if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')
31 31
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts
index 2b7cb5177..2eb872169 100755
--- a/scripts/create-transcoding-job.ts
+++ b/scripts/create-transcoding-job.ts
@@ -29,7 +29,7 @@ run()
29async function run () { 29async function run () {
30 await initDatabaseModels(true) 30 await initDatabaseModels(true)
31 31
32 const video = await VideoModel.loadByUUIDWithFile(program['video']) 32 const video = await VideoModel.loadByUUID(program['video'])
33 if (!video) throw new Error('Video not found.') 33 if (!video) throw new Error('Video not found.')
34 34
35 const dataInput: VideoTranscodingPayload = program.resolution !== undefined 35 const dataInput: VideoTranscodingPayload = program.resolution !== undefined
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts
index 4953a7439..d6dff8247 100755
--- a/scripts/prune-storage.ts
+++ b/scripts/prune-storage.ts
@@ -3,9 +3,12 @@ import { join } from 'path'
3import { CONFIG } from '../server/initializers/config' 3import { CONFIG } from '../server/initializers/config'
4import { VideoModel } from '../server/models/video/video' 4import { VideoModel } from '../server/models/video/video'
5import { initDatabaseModels } from '../server/initializers' 5import { initDatabaseModels } from '../server/initializers'
6import { remove, readdir } from 'fs-extra' 6import { readdir, remove } from 'fs-extra'
7import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy' 7import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
8import * as Bluebird from 'bluebird'
8import { getUUIDFromFilename } from '../server/helpers/utils' 9import { getUUIDFromFilename } from '../server/helpers/utils'
10import { ThumbnailModel } from '../server/models/video/thumbnail'
11import { AvatarModel } from '../server/models/avatar/avatar'
9 12
10run() 13run()
11 .then(() => process.exit(0)) 14 .then(() => process.exit(0))
@@ -17,25 +20,19 @@ run()
17async function run () { 20async function run () {
18 await initDatabaseModels(true) 21 await initDatabaseModels(true)
19 22
20 const storageOnlyOwnedToPrune = [ 23 let toDelete: string[] = []
21 CONFIG.STORAGE.VIDEOS_DIR,
22 CONFIG.STORAGE.TORRENTS_DIR,
23 CONFIG.STORAGE.REDUNDANCY_DIR
24 ]
25 24
26 const storageForAllToPrune = [ 25 toDelete = toDelete.concat(
27 CONFIG.STORAGE.PREVIEWS_DIR, 26 await pruneDirectory(CONFIG.STORAGE.VIDEOS_DIR, doesVideoExist(true)),
28 CONFIG.STORAGE.THUMBNAILS_DIR 27 await pruneDirectory(CONFIG.STORAGE.TORRENTS_DIR, doesVideoExist(true)),
29 ]
30 28
31 let toDelete: string[] = [] 29 await pruneDirectory(CONFIG.STORAGE.REDUNDANCY_DIR, doesRedundancyExist),
32 for (const directory of storageOnlyOwnedToPrune) {
33 toDelete = toDelete.concat(await pruneDirectory(directory, true))
34 }
35 30
36 for (const directory of storageForAllToPrune) { 31 await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true)),
37 toDelete = toDelete.concat(await pruneDirectory(directory, false)) 32 await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false)),
38 } 33
34 await pruneDirectory(CONFIG.STORAGE.AVATARS_DIR, doesAvatarExist)
35 )
39 36
40 const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR) 37 const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR)
41 toDelete = toDelete.concat(tmpFiles.map(t => join(CONFIG.STORAGE.TMP_DIR, t))) 38 toDelete = toDelete.concat(tmpFiles.map(t => join(CONFIG.STORAGE.TMP_DIR, t)))
@@ -61,30 +58,79 @@ async function run () {
61 } 58 }
62} 59}
63 60
64async function pruneDirectory (directory: string, onlyOwned = false) { 61type ExistFun = (file: string) => Promise<boolean>
62async function pruneDirectory (directory: string, existFun: ExistFun) {
65 const files = await readdir(directory) 63 const files = await readdir(directory)
66 64
67 const toDelete: string[] = [] 65 const toDelete: string[] = []
68 for (const file of files) { 66 await Bluebird.map(files, async file => {
67 if (await existFun(file) !== true) {
68 toDelete.push(join(directory, file))
69 }
70 }, { concurrency: 20 })
71
72 return toDelete
73}
74
75function doesVideoExist (keepOnlyOwned: boolean) {
76 return async (file: string) => {
69 const uuid = getUUIDFromFilename(file) 77 const uuid = getUUIDFromFilename(file)
70 let video: VideoModel 78 const video = await VideoModel.loadByUUID(uuid)
71 let localRedundancy: boolean
72 79
73 if (uuid) { 80 return video && (keepOnlyOwned === false || video.isOwned())
74 video = await VideoModel.loadByUUIDWithFile(uuid) 81 }
75 localRedundancy = await VideoRedundancyModel.isLocalByVideoUUIDExists(uuid) 82}
76 }
77 83
78 if ( 84function doesThumbnailExist (keepOnlyOwned: boolean) {
79 !uuid || 85 return async (file: string) => {
80 !video || 86 const thumbnail = await ThumbnailModel.loadByName(file)
81 (onlyOwned === true && (video.isOwned() === false && localRedundancy === false)) 87 if (!thumbnail) return false
82 ) { 88
83 toDelete.push(join(directory, file)) 89 if (keepOnlyOwned) {
90 const video = await VideoModel.load(thumbnail.videoId)
91 if (video.isOwned() === false) return false
84 } 92 }
93
94 return true
85 } 95 }
96}
86 97
87 return toDelete 98async function doesAvatarExist (file: string) {
99 const avatar = await AvatarModel.loadByName(file)
100
101 return !!avatar
102}
103
104async function doesRedundancyExist (file: string) {
105 const uuid = getUUIDFromFilename(file)
106 const video = await VideoModel.loadWithFiles(uuid)
107
108 if (!video) return false
109
110 const isPlaylist = file.includes('.') === false
111
112 if (isPlaylist) {
113 const p = video.getHLSPlaylist()
114 if (!p) return false
115
116 const redundancy = await VideoRedundancyModel.loadLocalByStreamingPlaylistId(p.id)
117 return !!redundancy
118 }
119
120 const resolution = parseInt(file.split('-')[5], 10)
121 if (isNaN(resolution)) {
122 console.error('Cannot prune %s because we cannot guess guess the resolution.', file)
123 return true
124 }
125
126 const videoFile = video.getFile(resolution)
127 if (!videoFile) {
128 console.error('Cannot find file of video %s - %d', video.url, resolution)
129 return true
130 }
131
132 const redundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id)
133 return !!redundancy
88} 134}
89 135
90async function askConfirmation () { 136async function askConfirmation () {
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 4285fd727..28d2f862a 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -49,7 +49,12 @@ async function getAvatar (req: express.Request, res: express.Response) {
49 49
50 logger.info('Lazy serve remote avatar image %s.', avatar.fileUrl) 50 logger.info('Lazy serve remote avatar image %s.', avatar.fileUrl)
51 51
52 await pushAvatarProcessInQueue({ filename: avatar.filename, fileUrl: avatar.fileUrl }) 52 try {
53 await pushAvatarProcessInQueue({ filename: avatar.filename, fileUrl: avatar.fileUrl })
54 } catch (err) {
55 logger.warn('Cannot process remote avatar %s.', avatar.fileUrl, { err })
56 return res.sendStatus(404)
57 }
53 58
54 avatar.onDisk = true 59 avatar.onDisk = true
55 avatar.save() 60 avatar.save()
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts
index a68619d07..3da6bb138 100644
--- a/server/lib/files-cache/videos-preview-cache.ts
+++ b/server/lib/files-cache/videos-preview-cache.ts
@@ -18,7 +18,7 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
18 } 18 }
19 19
20 async getFilePathImpl (videoUUID: string) { 20 async getFilePathImpl (videoUUID: string) {
21 const video = await VideoModel.loadByUUIDWithFile(videoUUID) 21 const video = await VideoModel.loadByUUID(videoUUID)
22 if (!video) return undefined 22 if (!video) return undefined
23 23
24 if (video.isOwned()) return { isOwned: true, path: video.getPreview().getPath() } 24 if (video.isOwned()) return { isOwned: true, path: video.getPreview().getPath() }
diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts
index cf2040cbf..f1952dcc1 100644
--- a/server/models/video/thumbnail.ts
+++ b/server/models/video/thumbnail.ts
@@ -100,6 +100,16 @@ export class ThumbnailModel extends Model<ThumbnailModel> {
100 .catch(err => logger.error('Cannot remove thumbnail file %s.', instance.filename, err)) 100 .catch(err => logger.error('Cannot remove thumbnail file %s.', instance.filename, err))
101 } 101 }
102 102
103 static loadByName (filename: string) {
104 const query = {
105 where: {
106 filename
107 }
108 }
109
110 return ThumbnailModel.findOne(query)
111 }
112
103 static generateDefaultPreviewName (videoUUID: string) { 113 static generateDefaultPreviewName (videoUUID: string) {
104 return videoUUID + '.jpg' 114 return videoUUID + '.jpg'
105 } 115 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 1321337ff..b59df397d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -119,6 +119,7 @@ import { CONFIG } from '../../initializers/config'
119import { ThumbnailModel } from './thumbnail' 119import { ThumbnailModel } from './thumbnail'
120import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' 120import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
121import { createTorrentPromise } from '../../helpers/webtorrent' 121import { createTorrentPromise } from '../../helpers/webtorrent'
122import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
122 123
123// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation 124// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
124const indexes: (ModelIndexesOptions & { where?: WhereOptions })[] = [ 125const indexes: (ModelIndexesOptions & { where?: WhereOptions })[] = [
@@ -1422,15 +1423,23 @@ export class VideoModel extends Model<VideoModel> {
1422 return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) 1423 return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
1423 } 1424 }
1424 1425
1425 static loadWithFiles (id: number, t?: Transaction, logging?: boolean) { 1426 static loadWithFiles (id: number | string, t?: Transaction, logging?: boolean) {
1427 const where = buildWhereIdOrUUID(id)
1428
1429 const query = {
1430 where,
1431 transaction: t,
1432 logging
1433 }
1434
1426 return VideoModel.scope([ 1435 return VideoModel.scope([
1427 ScopeNames.WITH_FILES, 1436 ScopeNames.WITH_FILES,
1428 ScopeNames.WITH_STREAMING_PLAYLISTS, 1437 ScopeNames.WITH_STREAMING_PLAYLISTS,
1429 ScopeNames.WITH_THUMBNAILS 1438 ScopeNames.WITH_THUMBNAILS
1430 ]).findByPk(id, { transaction: t, logging }) 1439 ]).findOne(query)
1431 } 1440 }
1432 1441
1433 static loadByUUIDWithFile (uuid: string) { 1442 static loadByUUID (uuid: string) {
1434 const options = { 1443 const options = {
1435 where: { 1444 where: {
1436 uuid 1445 uuid
@@ -1754,7 +1763,7 @@ export class VideoModel extends Model<VideoModel> {
1754 return maxBy(this.VideoFiles, file => file.resolution) 1763 return maxBy(this.VideoFiles, file => file.resolution)
1755 } 1764 }
1756 1765
1757 getFile (resolution: VideoResolution) { 1766 getFile (resolution: number) {
1758 if (Array.isArray(this.VideoFiles) === false) return undefined 1767 if (Array.isArray(this.VideoFiles) === false) return undefined
1759 1768
1760 return this.VideoFiles.find(f => f.resolution === resolution) 1769 return this.VideoFiles.find(f => f.resolution === resolution)
@@ -1893,6 +1902,12 @@ export class VideoModel extends Model<VideoModel> {
1893 return `/api/${API_VERSION}/videos/${this.uuid}/description` 1902 return `/api/${API_VERSION}/videos/${this.uuid}/description`
1894 } 1903 }
1895 1904
1905 getHLSPlaylist () {
1906 if (!this.VideoStreamingPlaylists) return undefined
1907
1908 return this.VideoStreamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
1909 }
1910
1896 removeFile (videoFile: VideoFileModel, isRedundancy = false) { 1911 removeFile (videoFile: VideoFileModel, isRedundancy = false) {
1897 const baseDir = isRedundancy ? CONFIG.STORAGE.REDUNDANCY_DIR : CONFIG.STORAGE.VIDEOS_DIR 1912 const baseDir = isRedundancy ? CONFIG.STORAGE.REDUNDANCY_DIR : CONFIG.STORAGE.VIDEOS_DIR
1898 1913
diff --git a/server/tests/cli/index.ts b/server/tests/cli/index.ts
index 5af286fe2..029cd5196 100644
--- a/server/tests/cli/index.ts
+++ b/server/tests/cli/index.ts
@@ -4,5 +4,6 @@ import './create-transcoding-job'
4import './optimize-old-videos' 4import './optimize-old-videos'
5import './peertube' 5import './peertube'
6import './plugins' 6import './plugins'
7import './prune-storage'
7import './reset-password' 8import './reset-password'
8import './update-host' 9import './update-host'
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
new file mode 100644
index 000000000..67a5c564e
--- /dev/null
+++ b/server/tests/cli/prune-storage.ts
@@ -0,0 +1,199 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5import { waitJobs } from '../../../shared/extra-utils/server/jobs'
6import {
7 buildServerDirectory,
8 cleanupTests,
9 createVideoPlaylist,
10 doubleFollow,
11 execCLI,
12 flushAndRunMultipleServers,
13 getAccount,
14 getEnvCli,
15 ServerInfo,
16 setAccessTokensToServers, setDefaultVideoChannel,
17 updateMyAvatar,
18 uploadVideo,
19 wait
20} from '../../../shared/extra-utils'
21import { Account, VideoPlaylistPrivacy } from '../../../shared/models'
22import { createFile, readdir } from 'fs-extra'
23import * as uuidv4 from 'uuid/v4'
24import { join } from 'path'
25import * as request from 'supertest'
26
27const expect = chai.expect
28
29async function countFiles (internalServerNumber: number, directory: string) {
30 const files = await readdir(buildServerDirectory(internalServerNumber, directory))
31
32 return files.length
33}
34
35async function assertNotExists (internalServerNumber: number, directory: string, substring: string) {
36 const files = await readdir(buildServerDirectory(internalServerNumber, directory))
37
38 for (const f of files) {
39 expect(f).to.not.contain(substring)
40 }
41}
42
43async function assertCountAreOkay (servers: ServerInfo[]) {
44 for (const server of servers) {
45 const videosCount = await countFiles(server.internalServerNumber, 'videos')
46 expect(videosCount).to.equal(8)
47
48 const torrentsCount = await countFiles(server.internalServerNumber, 'torrents')
49 expect(torrentsCount).to.equal(8)
50
51 const previewsCount = await countFiles(server.internalServerNumber, 'previews')
52 expect(previewsCount).to.equal(2)
53
54 const thumbnailsCount = await countFiles(server.internalServerNumber, 'thumbnails')
55 expect(thumbnailsCount).to.equal(6)
56
57 const avatarsCount = await countFiles(server.internalServerNumber, 'avatars')
58 expect(avatarsCount).to.equal(2)
59 }
60}
61
62describe('Test prune storage scripts', function () {
63 let servers: ServerInfo[]
64 const badNames: { [ directory: string ]: string[] } = {}
65
66 before(async function () {
67 this.timeout(120000)
68
69 servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: true } })
70 await setAccessTokensToServers(servers)
71 await setDefaultVideoChannel(servers)
72
73 for (const server of servers) {
74 await uploadVideo(server.url, server.accessToken, { name: 'video 1' })
75 await uploadVideo(server.url, server.accessToken, { name: 'video 2' })
76
77 await updateMyAvatar({ url: server.url, accessToken: server.accessToken, fixture: 'avatar.png' })
78
79 await createVideoPlaylist({
80 url: server.url,
81 token: server.accessToken,
82 playlistAttrs: {
83 displayName: 'playlist',
84 privacy: VideoPlaylistPrivacy.PUBLIC,
85 videoChannelId: server.videoChannel.id,
86 thumbnailfile: 'thumbnail.jpg'
87 }
88 })
89 }
90
91 await doubleFollow(servers[0], servers[1])
92
93 // Lazy load the remote avatar
94 {
95 const res = await getAccount(servers[ 0 ].url, 'root@localhost:' + servers[ 1 ].port)
96 const account: Account = res.body
97 await request('http://localhost:' + servers[ 0 ].port).get(account.avatar.path).expect(200)
98 }
99
100 {
101 const res = await getAccount(servers[ 1 ].url, 'root@localhost:' + servers[ 0 ].port)
102 const account: Account = res.body
103 await request('http://localhost:' + servers[ 1 ].port).get(account.avatar.path).expect(200)
104 }
105
106 await wait(1000)
107
108 await waitJobs(servers)
109 })
110
111 it('Should have the files on the disk', async function () {
112 await assertCountAreOkay(servers)
113 })
114
115 it('Should create some dirty files', async function () {
116 for (let i = 0; i < 2; i++) {
117 {
118 const base = buildServerDirectory(servers[0].internalServerNumber, 'videos')
119
120 const n1 = uuidv4() + '.mp4'
121 const n2 = uuidv4() + '.webm'
122
123 await createFile(join(base, n1))
124 await createFile(join(base, n2))
125
126 badNames['videos'] = [ n1, n2 ]
127 }
128
129 {
130 const base = buildServerDirectory(servers[0].internalServerNumber, 'torrents')
131
132 const n1 = uuidv4() + '-240.torrent'
133 const n2 = uuidv4() + '-480.torrent'
134
135 await createFile(join(base, n1))
136 await createFile(join(base, n2))
137
138 badNames['torrents'] = [ n1, n2 ]
139 }
140
141 {
142 const base = buildServerDirectory(servers[0].internalServerNumber, 'thumbnails')
143
144 const n1 = uuidv4() + '.jpg'
145 const n2 = uuidv4() + '.jpg'
146
147 await createFile(join(base, n1))
148 await createFile(join(base, n2))
149
150 badNames['thumbnails'] = [ n1, n2 ]
151 }
152
153 {
154 const base = buildServerDirectory(servers[0].internalServerNumber, 'previews')
155
156 const n1 = uuidv4() + '.jpg'
157 const n2 = uuidv4() + '.jpg'
158
159 await createFile(join(base, n1))
160 await createFile(join(base, n2))
161
162 badNames['previews'] = [ n1, n2 ]
163 }
164
165 {
166 const base = buildServerDirectory(servers[0].internalServerNumber, 'avatars')
167
168 const n1 = uuidv4() + '.png'
169 const n2 = uuidv4() + '.jpg'
170
171 await createFile(join(base, n1))
172 await createFile(join(base, n2))
173
174 badNames['avatars'] = [ n1, n2 ]
175 }
176 }
177 })
178
179 it('Should run prune storage', async function () {
180 this.timeout(30000)
181
182 const env = getEnvCli(servers[0])
183 await execCLI(`echo y | ${env} npm run prune-storage`)
184 })
185
186 it('Should have removed files', async function () {
187 await assertCountAreOkay(servers)
188
189 for (const directory of Object.keys(badNames)) {
190 for (const name of badNames[directory]) {
191 await assertNotExists(servers[0].internalServerNumber, directory, name)
192 }
193 }
194 })
195
196 after(async function () {
197 await cleanupTests(servers)
198 })
199})
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts
index ae8a26c98..6b0f6d990 100644
--- a/shared/extra-utils/miscs/miscs.ts
+++ b/shared/extra-utils/miscs/miscs.ts
@@ -44,6 +44,10 @@ function root () {
44 return root 44 return root
45} 45}
46 46
47function buildServerDirectory (internalServerNumber: number, directory: string) {
48 return join(root(), 'test' + internalServerNumber, directory)
49}
50
47async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { 51async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
48 const res = await request(url) 52 const res = await request(url)
49 .get(imagePath) 53 .get(imagePath)
@@ -105,6 +109,7 @@ async function generateHighBitrateVideo () {
105export { 109export {
106 dateIsValid, 110 dateIsValid,
107 wait, 111 wait,
112 buildServerDirectory,
108 webtorrentAdd, 113 webtorrentAdd,
109 immutableAssign, 114 immutableAssign,
110 testImage, 115 testImage,
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 1533f37ab..75f7d58d7 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -19,7 +19,7 @@ import {
19import * as validator from 'validator' 19import * as validator from 'validator'
20import { VideoDetails, VideoPrivacy } from '../../models/videos' 20import { VideoDetails, VideoPrivacy } from '../../models/videos'
21import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, loadLanguages, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 21import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, loadLanguages, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
22import { dateIsValid, webtorrentAdd } from '../miscs/miscs' 22import { dateIsValid, webtorrentAdd, buildServerDirectory } from '../miscs/miscs'
23 23
24loadLanguages() 24loadLanguages()
25 25
@@ -308,10 +308,8 @@ async function checkVideoFilesWereRemoved (
308 join('redundancy', 'hls') 308 join('redundancy', 'hls')
309 ] 309 ]
310) { 310) {
311 const testDirectory = 'test' + serverNumber
312
313 for (const directory of directories) { 311 for (const directory of directories) {
314 const directoryPath = join(root(), testDirectory, directory) 312 const directoryPath = buildServerDirectory(serverNumber, directory)
315 313
316 const directoryExists = await pathExists(directoryPath) 314 const directoryExists = await pathExists(directoryPath)
317 if (directoryExists === false) continue 315 if (directoryExists === false) continue