Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Put config redundancy strategies in "strategies" subkey

Chocobozzzd9bdd007d7a1
diff --git a/config/default.yaml b/config/default.yaml
index ab07bfeddc..00eeaea8c4 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -71,16 +71,17 @@ trending:
# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following
redundancy:
videos:
-# -
-# size: '10GB'
-# strategy: 'most-views' # Cache videos that have the most views
-# -
-# size: '10GB'
-# strategy: 'trending' # Cache trending videos
-# -
-# size: '10GB'
-# strategy: 'recently-added' # Cache recently added videos
-# minViews: 10 # Having at least x views
+ strategies:
+# -
+# size: '10GB'
+# strategy: 'most-views' # Cache videos that have the most views
+# -
+# size: '10GB'
+# strategy: 'trending' # Cache trending videos
+# -
+# size: '10GB'
+# strategy: 'recently-added' # Cache recently added videos
+# minViews: 10 # Having at least x views
cache:
previews:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index f9557b8eb9..28770e480c 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -72,16 +72,17 @@ trending:
# Once you have defined your strategies, choose which instances you want to cache in admin -> manage follows -> following
redundancy:
videos:
-# -
-# size: '10GB'
-# strategy: 'most-views' # Cache videos that have the most views
-# -
-# size: '10GB'
-# strategy: 'trending' # Cache trending videos
-# -
-# size: '10GB'
-# strategy: 'recently-added' # Cache recently added videos
-# minViews: 10 # Having at least x views
+ strategies:
+# -
+# size: '10GB'
+# strategy: 'most-views' # Cache videos that have the most views
+# -
+# size: '10GB'
+# strategy: 'trending' # Cache trending videos
+# -
+# size: '10GB'
+# strategy: 'recently-added' # Cache recently added videos
+# minViews: 10 # Having at least x views
###############################################################################
#
diff --git a/config/test.yaml b/config/test.yaml
index d3e0e49ac7..d36d90bbd7 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -23,16 +23,17 @@ log:
redundancy:
videos:
- -
- size: '10MB'
- strategy: 'most-views'
- -
- size: '10MB'
- strategy: 'trending'
- -
- size: '10MB'
- strategy: 'recently-added'
- minViews: 1
+ strategies:
+ -
+ size: '10MB'
+ strategy: 'most-views'
+ -
+ size: '10MB'
+ strategy: 'trending'
+ -
+ size: '10MB'
+ strategy: 'recently-added'
+ minViews: 1
cache:
previews:
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts
index bb6311e81c..85803f69ee 100644
--- a/server/controllers/api/server/stats.ts
+++ b/server/controllers/api/server/stats.ts
@@ -23,7 +23,7 @@ async function getStats (req: express.Request, res: express.Response, next: expr
const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats()
const videosRedundancyStats = await Promise.all(
- CONFIG.REDUNDANCY.VIDEOS.map(r => {
+ CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.map(r => {
return VideoRedundancyModel.getStats(r.strategy)
.then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
})
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index b9dc1e7254..8b52808487 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -40,7 +40,7 @@ function checkConfig () {
}
// Redundancies
- const redundancyVideos = config.get<VideosRedundancy[]>('redundancy.videos')
+ const redundancyVideos = config.get<VideosRedundancy[]>('redundancy.videos.strategies')
if (isArray(redundancyVideos)) {
for (const r of redundancyVideos) {
if ([ 'most-views', 'trending', 'recently-added' ].indexOf(r.strategy) === -1) {
@@ -75,6 +75,7 @@ function checkMissedConfig () {
'cache.previews.size', 'admin.email',
'signup.enabled', 'signup.limit', 'signup.requires_email_verification',
'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
+ 'redundancy.videos.strategies',
'transcoding.enabled', 'transcoding.threads',
'import.videos.http.enabled', 'import.videos.torrent.enabled',
'trending.videos.interval_days',
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index fa90939186..881978753b 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -212,7 +212,9 @@ const CONFIG = {
}
},
REDUNDANCY: {
- VIDEOS: buildVideosRedundancy(config.get<any[]>('redundancy.videos'))
+ VIDEOS: {
+ STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
+ }
},
ADMIN: {
get EMAIL () { return config.get<string>('admin.email') }
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 0bdb7d12ea..d37a695a72 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -78,6 +78,9 @@ async function getOrCreateActorAndServerAndModel (
created = true
}
+ if (actor.Account) actor.Account.Actor = actor
+ if (actor.VideoChannel) actor.VideoChannel.Actor = actor
+
const { actor: actorRefreshed, refreshed } = await retryTransactionWrapper(refreshActorIfNeeded, actor, fetchType)
if (!actorRefreshed) throw new Error('Actor ' + actorRefreshed.url + ' does not exist anymore.')
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index 7079600a9c..5f9fd99112 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -1,10 +1,9 @@
import { AbstractScheduler } from './abstract-scheduler'
import { CONFIG, JOB_TTL, REDUNDANCY, SCHEDULER_INTERVALS_MS } from '../../initializers'
import { logger } from '../../helpers/logger'
-import { RecentlyAddedStrategy, VideoRedundancyStrategy, VideosRedundancy } from '../../../shared/models/redundancy'
+import { VideoRedundancyStrategy, VideosRedundancy } from '../../../shared/models/redundancy'
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
import { VideoFileModel } from '../../models/video/video-file'
-import { sortBy } from 'lodash'
import { downloadWebTorrentVideo } from '../../helpers/webtorrent'
import { join } from 'path'
import { rename } from 'fs-extra'
@@ -12,7 +11,6 @@ import { getServerActor } from '../../helpers/utils'
import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
import { VideoModel } from '../../models/video/video'
import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
-import { removeVideoRedundancy } from '../redundancy'
import { isTestInstance } from '../../helpers/core-utils'
export class VideosRedundancyScheduler extends AbstractScheduler {
@@ -31,7 +29,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
this.executing = true
- for (const obj of CONFIG.REDUNDANCY.VIDEOS) {
+ for (const obj of CONFIG.REDUNDANCY.VIDEOS.STRATEGIES) {
try {
const videoToDuplicate = await this.findVideoToDuplicate(obj)
if (!videoToDuplicate) continue
diff --git a/server/models/video/tag.ts b/server/models/video/tag.ts
index e39a418cdf..b39621eaf4 100644
--- a/server/models/video/tag.ts
+++ b/server/models/video/tag.ts
@@ -48,11 +48,10 @@ export class TagModel extends Model<TagModel> {
},
defaults: {
name: tag
- }
+ },
+ transaction
}
- if (transaction) query['transaction'] = transaction
-
const promise = TagModel.findOrCreate(query)
.then(([ tagInstance ]) => tagInstance)
tasks.push(promise)