diff options
Diffstat (limited to 'server/lib/schedulers')
6 files changed, 24 insertions, 26 deletions
diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/lib/schedulers/actor-follow-scheduler.ts index 598c0211f..1b80316e9 100644 --- a/server/lib/schedulers/actor-follow-scheduler.ts +++ b/server/lib/schedulers/actor-follow-scheduler.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { isTestInstance } from '../../helpers/core-utils' | 1 | import { isTestInstance } from '../../helpers/core-utils' |
2 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | ||
4 | import { AbstractScheduler } from './abstract-scheduler' | ||
5 | import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | 3 | import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
4 | import { ActorFollowModel } from '../../models/actor/actor-follow' | ||
6 | import { ActorFollowScoreCache } from '../files-cache' | 5 | import { ActorFollowScoreCache } from '../files-cache' |
6 | import { AbstractScheduler } from './abstract-scheduler' | ||
7 | 7 | ||
8 | export class ActorFollowScheduler extends AbstractScheduler { | 8 | export class ActorFollowScheduler extends AbstractScheduler { |
9 | 9 | ||
diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index 0b8cd1389..aaa5feed5 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { chunk } from 'lodash' | 1 | import { chunk } from 'lodash' |
2 | import { doJSONRequest } from '@server/helpers/requests' | 2 | import { doJSONRequest } from '@server/helpers/requests' |
3 | import { JobQueue } from '@server/lib/job-queue' | 3 | import { JobQueue } from '@server/lib/job-queue' |
4 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | 4 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
5 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { CONFIG } from '../../initializers/config' | 7 | import { CONFIG } from '../../initializers/config' |
diff --git a/server/lib/schedulers/remove-old-history-scheduler.ts b/server/lib/schedulers/remove-old-history-scheduler.ts index 17a42b2c4..225669ea2 100644 --- a/server/lib/schedulers/remove-old-history-scheduler.ts +++ b/server/lib/schedulers/remove-old-history-scheduler.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { logger } from '../../helpers/logger' | 1 | import { logger } from '../../helpers/logger' |
2 | import { AbstractScheduler } from './abstract-scheduler' | 2 | import { AbstractScheduler } from './abstract-scheduler' |
3 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | 3 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
4 | import { UserVideoHistoryModel } from '../../models/account/user-video-history' | 4 | import { UserVideoHistoryModel } from '../../models/user/user-video-history' |
5 | import { CONFIG } from '../../initializers/config' | 5 | import { CONFIG } from '../../initializers/config' |
6 | 6 | ||
7 | export class RemoveOldHistoryScheduler extends AbstractScheduler { | 7 | export class RemoveOldHistoryScheduler extends AbstractScheduler { |
diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index 3e75babcb..af69bda89 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import { VideoModel } from '@server/models/video/video' | ||
2 | import { MVideoFullLight } from '@server/types/models' | ||
1 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
2 | import { AbstractScheduler } from './abstract-scheduler' | 4 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
5 | import { sequelizeTypescript } from '../../initializers/database' | ||
3 | import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' | 6 | import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' |
4 | import { retryTransactionWrapper } from '../../helpers/database-utils' | ||
5 | import { federateVideoIfNeeded } from '../activitypub/videos' | 7 | import { federateVideoIfNeeded } from '../activitypub/videos' |
6 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | ||
7 | import { Notifier } from '../notifier' | 8 | import { Notifier } from '../notifier' |
8 | import { sequelizeTypescript } from '../../initializers/database' | 9 | import { AbstractScheduler } from './abstract-scheduler' |
9 | import { MVideoFullLight } from '@server/types/models' | ||
10 | 10 | ||
11 | export class UpdateVideosScheduler extends AbstractScheduler { | 11 | export class UpdateVideosScheduler extends AbstractScheduler { |
12 | 12 | ||
@@ -19,18 +19,19 @@ export class UpdateVideosScheduler extends AbstractScheduler { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | protected async internalExecute () { | 21 | protected async internalExecute () { |
22 | return retryTransactionWrapper(this.updateVideos.bind(this)) | 22 | return this.updateVideos() |
23 | } | 23 | } |
24 | 24 | ||
25 | private async updateVideos () { | 25 | private async updateVideos () { |
26 | if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined | 26 | if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined |
27 | 27 | ||
28 | const publishedVideos = await sequelizeTypescript.transaction(async t => { | 28 | const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate() |
29 | const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) | 29 | const publishedVideos: MVideoFullLight[] = [] |
30 | const publishedVideos: MVideoFullLight[] = [] | 30 | |
31 | for (const schedule of schedules) { | ||
32 | await sequelizeTypescript.transaction(async t => { | ||
33 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(schedule.videoId, t) | ||
31 | 34 | ||
32 | for (const schedule of schedules) { | ||
33 | const video = schedule.Video | ||
34 | logger.info('Executing scheduled video update on %s.', video.uuid) | 35 | logger.info('Executing scheduled video update on %s.', video.uuid) |
35 | 36 | ||
36 | if (schedule.privacy) { | 37 | if (schedule.privacy) { |
@@ -42,16 +43,13 @@ export class UpdateVideosScheduler extends AbstractScheduler { | |||
42 | await federateVideoIfNeeded(video, isNewVideo, t) | 43 | await federateVideoIfNeeded(video, isNewVideo, t) |
43 | 44 | ||
44 | if (wasConfidentialVideo) { | 45 | if (wasConfidentialVideo) { |
45 | const videoToPublish: MVideoFullLight = Object.assign(video, { ScheduleVideoUpdate: schedule, UserVideoHistories: [] }) | 46 | publishedVideos.push(video) |
46 | publishedVideos.push(videoToPublish) | ||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | await schedule.destroy({ transaction: t }) | 50 | await schedule.destroy({ transaction: t }) |
51 | } | 51 | }) |
52 | 52 | } | |
53 | return publishedVideos | ||
54 | }) | ||
55 | 53 | ||
56 | for (const v of publishedVideos) { | 54 | for (const v of publishedVideos) { |
57 | Notifier.Instance.notifyOnNewVideoIfNeeded(v) | 55 | Notifier.Instance.notifyOnNewVideoIfNeeded(v) |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 59b55cccc..b5a5eb697 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -23,7 +23,7 @@ import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../. | |||
23 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 23 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
24 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 24 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
25 | import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' | 25 | import { getLocalVideoCacheFileActivityPubUrl, getLocalVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' |
26 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos' | 26 | import { getOrCreateAPVideo } from '../activitypub/videos' |
27 | import { downloadPlaylistSegments } from '../hls' | 27 | import { downloadPlaylistSegments } from '../hls' |
28 | import { removeVideoRedundancy } from '../redundancy' | 28 | import { removeVideoRedundancy } from '../redundancy' |
29 | import { generateHLSRedundancyUrl, generateWebTorrentRedundancyUrl } from '../video-paths' | 29 | import { generateHLSRedundancyUrl, generateWebTorrentRedundancyUrl } from '../video-paths' |
@@ -351,7 +351,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
351 | syncParam: { likes: false, dislikes: false, shares: false, comments: false, thumbnail: false, refreshVideo: true }, | 351 | syncParam: { likes: false, dislikes: false, shares: false, comments: false, thumbnail: false, refreshVideo: true }, |
352 | fetchType: 'all' as 'all' | 352 | fetchType: 'all' as 'all' |
353 | } | 353 | } |
354 | const { video } = await getOrCreateVideoAndAccountAndChannel(getVideoOptions) | 354 | const { video } = await getOrCreateAPVideo(getVideoOptions) |
355 | 355 | ||
356 | return video | 356 | return video |
357 | } | 357 | } |
diff --git a/server/lib/schedulers/youtube-dl-update-scheduler.ts b/server/lib/schedulers/youtube-dl-update-scheduler.ts index aefe6aba4..898691c13 100644 --- a/server/lib/schedulers/youtube-dl-update-scheduler.ts +++ b/server/lib/schedulers/youtube-dl-update-scheduler.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { AbstractScheduler } from './abstract-scheduler' | 1 | import { YoutubeDL } from '@server/helpers/youtube-dl' |
2 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | 2 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
3 | import { updateYoutubeDLBinary } from '../../helpers/youtube-dl' | 3 | import { AbstractScheduler } from './abstract-scheduler' |
4 | 4 | ||
5 | export class YoutubeDlUpdateScheduler extends AbstractScheduler { | 5 | export class YoutubeDlUpdateScheduler extends AbstractScheduler { |
6 | 6 | ||
@@ -13,7 +13,7 @@ export class YoutubeDlUpdateScheduler extends AbstractScheduler { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | protected internalExecute () { | 15 | protected internalExecute () { |
16 | return updateYoutubeDLBinary() | 16 | return YoutubeDL.updateYoutubeDLBinary() |
17 | } | 17 | } |
18 | 18 | ||
19 | static get Instance () { | 19 | static get Instance () { |