aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0075-video-resolutions.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-21 14:54:29 +0100
committerChocobozzz <me@florianbigard.com>2022-03-21 14:54:29 +0100
commit348c2ce3ff3fe2f25a31f08bfb36c88723a0ce46 (patch)
tree972ec51091bab14e7671ef7db3b6e43ea5f116f7 /server/initializers/migrations/0075-video-resolutions.ts
parente6afb669402aead6bf3d9d7ba4f2bd434c831eab (diff)
downloadPeerTube-348c2ce3ff3fe2f25a31f08bfb36c88723a0ce46.tar.gz
PeerTube-348c2ce3ff3fe2f25a31f08bfb36c88723a0ce46.tar.zst
PeerTube-348c2ce3ff3fe2f25a31f08bfb36c88723a0ce46.zip
Remove old migration files
Diffstat (limited to 'server/initializers/migrations/0075-video-resolutions.ts')
-rw-r--r--server/initializers/migrations/0075-video-resolutions.ts57
1 files changed, 0 insertions, 57 deletions
diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts
deleted file mode 100644
index 8cd47496e..000000000
--- a/server/initializers/migrations/0075-video-resolutions.ts
+++ /dev/null
@@ -1,57 +0,0 @@
1import { readdir, rename } from 'fs-extra'
2import { join } from 'path'
3import * as Sequelize from 'sequelize'
4import { getVideoStreamDimensionsInfo } from '../../helpers/ffmpeg/ffprobe-utils'
5import { CONFIG } from '../../initializers/config'
6
7function up (utils: {
8 transaction: Sequelize.Transaction
9 queryInterface: Sequelize.QueryInterface
10 sequelize: Sequelize.Sequelize
11 db: any
12}): Promise<void> {
13 const torrentDir = CONFIG.STORAGE.TORRENTS_DIR
14 const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR
15
16 return readdir(videoFileDir)
17 .then(videoFiles => {
18 const tasks: Promise<any>[] = []
19 for (const videoFile of videoFiles) {
20 const matches = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.([a-z0-9]+)/.exec(videoFile)
21 if (matches === null) {
22 console.log('Invalid video file name %s.', videoFile)
23 continue
24 }
25
26 const uuid = matches[1]
27 const ext = matches[2]
28
29 const p = getVideoStreamDimensionsInfo(join(videoFileDir, videoFile))
30 .then(async ({ resolution }) => {
31 const oldTorrentName = uuid + '.torrent'
32 const newTorrentName = uuid + '-' + resolution + '.torrent'
33 await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution)
34
35 const newVideoFileName = uuid + '-' + resolution + '.' + ext
36 await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution)
37
38 const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution +
39 ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')'
40 return utils.sequelize.query(query)
41 })
42
43 tasks.push(p)
44 }
45
46 return Promise.all(tasks).then(() => undefined)
47 })
48}
49
50function down (options) {
51 throw new Error('Not implemented.')
52}
53
54export {
55 up,
56 down
57}