aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/upload.ts
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-06-21 15:31:25 +0200
committerGitHub <noreply@github.com>2022-06-21 15:31:25 +0200
commit2e401e8575decb1d491d0db48ca1ab1eba5b2a66 (patch)
treeeee1e6213ca4d635837ca01c2bdc5c876b8d8b7d /server/controllers/api/videos/upload.ts
parentdec49521556fc228c6e05b6199e9b07f619b38fb (diff)
downloadPeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.gz
PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.tar.zst
PeerTube-2e401e8575decb1d491d0db48ca1ab1eba5b2a66.zip
store uploaded video filename (#4885)
* store uploaded video filename closes #4731 * dont crash if videos channel exist * migration: use raw query * video source: fixes after code review * cleanup * bump migration * updates after code review * refactor: use checkUserCanManageVideo * videoSource: add openapi doc * test(check-params/video-source): fix timeout * Styling * Correctly set original filename as source Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/controllers/api/videos/upload.ts')
-rw-r--r--server/controllers/api/videos/upload.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 3afbedbb2..c5890691e 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -44,6 +44,7 @@ import {
44import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 44import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
45import { VideoModel } from '../../../models/video/video' 45import { VideoModel } from '../../../models/video/video'
46import { VideoFileModel } from '../../../models/video/video-file' 46import { VideoFileModel } from '../../../models/video/video-file'
47import { VideoSourceModel } from '@server/models/video/video-source'
47 48
48const lTags = loggerTagsFactory('api', 'video') 49const lTags = loggerTagsFactory('api', 'video')
49const auditLogger = auditLoggerFactory('videos') 50const auditLogger = auditLoggerFactory('videos')
@@ -151,6 +152,7 @@ async function addVideo (options: {
151 video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 152 video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
152 153
153 const videoFile = await buildNewFile(videoPhysicalFile) 154 const videoFile = await buildNewFile(videoPhysicalFile)
155 const originalFilename = videoPhysicalFile.originalname
154 156
155 // Move physical file 157 // Move physical file
156 const destination = VideoPathManager.Instance.getFSVideoFileOutputPath(video, videoFile) 158 const destination = VideoPathManager.Instance.getFSVideoFileOutputPath(video, videoFile)
@@ -181,6 +183,11 @@ async function addVideo (options: {
181 183
182 video.VideoFiles = [ videoFile ] 184 video.VideoFiles = [ videoFile ]
183 185
186 await VideoSourceModel.create({
187 filename: originalFilename,
188 videoId: video.id
189 }, { transaction: t })
190
184 await setVideoTags({ video, tags: videoInfo.tags, transaction: t }) 191 await setVideoTags({ video, tags: videoInfo.tags, transaction: t })
185 192
186 // Schedule an update in the future? 193 // Schedule an update in the future?