From: Chocobozzz Date: Tue, 16 Jul 2019 13:03:00 +0000 (+0200) Subject: Check latest plugins version with config interval X-Git-Tag: v1.4.0-rc.1~108 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=d133f3858288b20d790e9bb57664fc6e22d9aeaf;hp=e0ce715a1ded6e84c877004dae3e354c8716fb06;p=github%2FChocobozzz%2FPeerTube.git Check latest plugins version with config interval --- diff --git a/config/default.yaml b/config/default.yaml index 341de49b8..a26625ab3 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -156,10 +156,11 @@ views: max_age: -1 plugins: - # The website PeerTube will ask for available PeerTube plugins - # This is an unmoderated plugin index, so only install plugins you trust + # The website PeerTube will ask for available PeerTube plugins and themes + # This is an unmoderated plugin index, so only install plugins/themes you trust index: enabled: true + check_latest_versions_interval: '1 day' # How often you want to check new plugins/themes versions url: 'https://packages.joinpeertube.org' cache: diff --git a/config/production.yaml.example b/config/production.yaml.example index 28f078efe..ec7744deb 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -161,6 +161,7 @@ plugins: # This is an unmoderated plugin index, so only install plugins you trust index: enabled: true + check_latest_versions_interval: '1 day' # How often you want to check new plugins/themes versions url: 'https://packages.joinpeertube.org' diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 2c1b30021..58241e4ea 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -137,7 +137,8 @@ const CONFIG = { PLUGINS: { INDEX: { ENABLED: config.get('plugins.index.enabled'), - URL: config.get('plugins.index.url') + CHECK_LATEST_VERSIONS_INTERVAL: parseDurationToMs(config.get('plugins.index.check_latest_versions_interval')), + URL: config.get('plugins.index.url') } }, ADMIN: { diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 367ae8d45..cd4d4e847 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -4,7 +4,7 @@ import { ActivityPubActorType } from '../../shared/models/activitypub' import { FollowState } from '../../shared/models/actors' import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' // Do not use barrels, remain constants as independent as possible -import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils' +import { isTestInstance, sanitizeHost, sanitizeUrl, root, parseDurationToMs } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' import { CronRepeatOptions, EveryRepeatOptions } from 'bull' @@ -167,7 +167,7 @@ const SCHEDULER_INTERVALS_MS = { removeOldJobs: 60000 * 60, // 1 hour updateVideos: 60000, // 1 minute youtubeDLUpdate: 60000 * 60 * 24, // 1 day - checkPlugins: 60000 * 60 * 24, // 1 day + checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, removeOldViews: 60000 * 60 * 24, // 1 day removeOldHistory: 60000 * 60 * 24 // 1 day } @@ -618,7 +618,6 @@ if (isTestInstance() === true) { SCHEDULER_INTERVALS_MS.removeOldHistory = 5000 SCHEDULER_INTERVALS_MS.removeOldViews = 5000 SCHEDULER_INTERVALS_MS.updateVideos = 5000 - SCHEDULER_INTERVALS_MS.checkPlugins = 10000 REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 diff --git a/server/lib/schedulers/plugins-check-scheduler.ts b/server/lib/schedulers/plugins-check-scheduler.ts index 8dfdd5177..7ff41e639 100644 --- a/server/lib/schedulers/plugins-check-scheduler.ts +++ b/server/lib/schedulers/plugins-check-scheduler.ts @@ -53,7 +53,7 @@ export class PluginsCheckScheduler extends AbstractScheduler { plugin.latestVersion = result.latestVersion await plugin.save() - logger.info('Plugin %s has a new latest version %s.', PluginModel.buildNpmName(plugin.name, plugin.type), plugin.latestVersion) + logger.info('Plugin %s has a new latest version %s.', result.npmName, plugin.latestVersion) } } } catch (err) {