diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2022-06-21 15:31:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 15:31:25 +0200 |
commit | 2e401e8575decb1d491d0db48ca1ab1eba5b2a66 (patch) | |
tree | eee1e6213ca4d635837ca01c2bdc5c876b8d8b7d /server/controllers/api/videos/upload.ts | |
parent | dec49521556fc228c6e05b6199e9b07f619b38fb (diff) | |
download | PeerTube-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.ts | 7 |
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 { | |||
44 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | 44 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' |
45 | import { VideoModel } from '../../../models/video/video' | 45 | import { VideoModel } from '../../../models/video/video' |
46 | import { VideoFileModel } from '../../../models/video/video-file' | 46 | import { VideoFileModel } from '../../../models/video/video-file' |
47 | import { VideoSourceModel } from '@server/models/video/video-source' | ||
47 | 48 | ||
48 | const lTags = loggerTagsFactory('api', 'video') | 49 | const lTags = loggerTagsFactory('api', 'video') |
49 | const auditLogger = auditLoggerFactory('videos') | 50 | const 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? |