diff options
Diffstat (limited to 'server/lib/schedulers')
-rw-r--r-- | server/lib/schedulers/update-videos-scheduler.ts | 8 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index 5b673b913..293bba91f 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts | |||
@@ -6,8 +6,8 @@ import { federateVideoIfNeeded } from '../activitypub' | |||
6 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | 6 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
7 | import { VideoPrivacy } from '../../../shared/models/videos' | 7 | import { VideoPrivacy } from '../../../shared/models/videos' |
8 | import { Notifier } from '../notifier' | 8 | import { Notifier } from '../notifier' |
9 | import { VideoModel } from '../../models/video/video' | ||
10 | import { sequelizeTypescript } from '../../initializers/database' | 9 | import { sequelizeTypescript } from '../../initializers/database' |
10 | import { MVideoFullLight } from '@server/typings/models' | ||
11 | 11 | ||
12 | export class UpdateVideosScheduler extends AbstractScheduler { | 12 | export class UpdateVideosScheduler extends AbstractScheduler { |
13 | 13 | ||
@@ -28,7 +28,7 @@ export class UpdateVideosScheduler extends AbstractScheduler { | |||
28 | 28 | ||
29 | const publishedVideos = await sequelizeTypescript.transaction(async t => { | 29 | const publishedVideos = await sequelizeTypescript.transaction(async t => { |
30 | const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) | 30 | const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) |
31 | const publishedVideos: VideoModel[] = [] | 31 | const publishedVideos: MVideoFullLight[] = [] |
32 | 32 | ||
33 | for (const schedule of schedules) { | 33 | for (const schedule of schedules) { |
34 | const video = schedule.Video | 34 | const video = schedule.Video |
@@ -45,8 +45,8 @@ export class UpdateVideosScheduler extends AbstractScheduler { | |||
45 | await federateVideoIfNeeded(video, isNewVideo, t) | 45 | await federateVideoIfNeeded(video, isNewVideo, t) |
46 | 46 | ||
47 | if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) { | 47 | if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) { |
48 | video.ScheduleVideoUpdate = schedule | 48 | const videoToPublish: MVideoFullLight = Object.assign(video, { ScheduleVideoUpdate: schedule, UserVideoHistories: [] }) |
49 | publishedVideos.push(video) | 49 | publishedVideos.push(videoToPublish) |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 1e30f6ebc..f2bd75cb4 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -3,7 +3,7 @@ import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } | |||
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { VideosRedundancy } from '../../../shared/models/redundancy' | 4 | import { VideosRedundancy } from '../../../shared/models/redundancy' |
5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
6 | import { downloadWebTorrentVideo } from '../../helpers/webtorrent' | 6 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { move } from 'fs-extra' | 8 | import { move } from 'fs-extra' |
9 | import { getServerActor } from '../../helpers/utils' | 9 | import { getServerActor } from '../../helpers/utils' |
@@ -24,6 +24,7 @@ import { | |||
24 | MVideoRedundancyVideo, | 24 | MVideoRedundancyVideo, |
25 | MVideoWithAllFiles | 25 | MVideoWithAllFiles |
26 | } from '@server/typings/models' | 26 | } from '@server/typings/models' |
27 | import { getVideoFilename } from '../video-paths' | ||
27 | 28 | ||
28 | type CandidateToDuplicate = { | 29 | type CandidateToDuplicate = { |
29 | redundancy: VideosRedundancy, | 30 | redundancy: VideosRedundancy, |
@@ -195,11 +196,11 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
195 | logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy) | 196 | logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy) |
196 | 197 | ||
197 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() | 198 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() |
198 | const magnetUri = video.generateMagnetUri(file, baseUrlHttp, baseUrlWs) | 199 | const magnetUri = await generateMagnetUri(video, file, baseUrlHttp, baseUrlWs) |
199 | 200 | ||
200 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) | 201 | const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT) |
201 | 202 | ||
202 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, video.getVideoFilename(file)) | 203 | const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, getVideoFilename(video, file)) |
203 | await move(tmpPath, destPath, { overwrite: true }) | 204 | await move(tmpPath, destPath, { overwrite: true }) |
204 | 205 | ||
205 | const createdModel: MVideoRedundancyFileVideo = await VideoRedundancyModel.create({ | 206 | const createdModel: MVideoRedundancyFileVideo = await VideoRedundancyModel.create({ |