aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/create-import-video-file-job.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-11 16:14:12 +0100
committerChocobozzz <me@florianbigard.com>2021-02-11 16:15:11 +0100
commit9aeef9aafa009762e128046bfb2f3cec3252e181 (patch)
tree300ed4599b2608cb5e848d85bc7ceccd17c90240 /scripts/create-import-video-file-job.ts
parentc83af8f94a3c9732c3ea02c80fa96441e5d99c0f (diff)
downloadPeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.tar.gz
PeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.tar.zst
PeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.zip
Check video UUID in args scripts
Diffstat (limited to 'scripts/create-import-video-file-job.ts')
-rw-r--r--scripts/create-import-video-file-job.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts
index f5271c7a3..5d38af066 100644
--- a/scripts/create-import-video-file-job.ts
+++ b/scripts/create-import-video-file-job.ts
@@ -6,6 +6,7 @@ import { resolve } from 'path'
6import { VideoModel } from '../server/models/video/video' 6import { VideoModel } from '../server/models/video/video'
7import { initDatabaseModels } from '../server/initializers/database' 7import { initDatabaseModels } from '../server/initializers/database'
8import { JobQueue } from '../server/lib/job-queue' 8import { JobQueue } from '../server/lib/job-queue'
9import { isUUIDValid } from '@server/helpers/custom-validators/misc'
9 10
10program 11program
11 .option('-v, --video [videoUUID]', 'Video UUID') 12 .option('-v, --video [videoUUID]', 'Video UUID')
@@ -30,6 +31,11 @@ run()
30async function run () { 31async function run () {
31 await initDatabaseModels(true) 32 await initDatabaseModels(true)
32 33
34 if (isUUIDValid(options.video) === false) {
35 console.error('%s is not a valid video UUID.', options.video)
36 return
37 }
38
33 const video = await VideoModel.loadByUUID(options.video) 39 const video = await VideoModel.loadByUUID(options.video)
34 if (!video) throw new Error('Video not found.') 40 if (!video) throw new Error('Video not found.')
35 if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') 41 if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')