Re enable the "seed all videos" function
authorChocobozzz <florian.bigard@gmail.com>
Tue, 28 Jun 2016 18:17:05 +0000 (20:17 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Tue, 28 Jun 2016 18:17:05 +0000 (20:17 +0200)
server.js
server/models/video.js

index 33e34019d96333f80f9b57fa60db0d9947f099b8..9322bca19e500038fced0335f8a644a09c786248 100644 (file)
--- a/server.js
+++ b/server.js
@@ -37,6 +37,7 @@ const routes = require('./server/controllers')
 const utils = require('./server/helpers/utils')
 const webtorrent = require('./server/lib/webtorrent')
 const Request = mongoose.model('Request')
+const Video = mongoose.model('Video')
 
 // Get configurations
 const port = config.get('listen.port')
@@ -139,11 +140,13 @@ installer.installApplication(function (err) {
       // Activate the pool requests
       Request.activate()
 
-      // videos.seedAllExisting(function () {
+      Video.seedAllExisting(function (err) {
+        if (err) throw err
+
         logger.info('Seeded all the videos')
         logger.info('Server listening on port %d', port)
         app.emit('ready')
-      // })
+      })
     })
   })
 })
index 8b14e9b35a1a02e695ea9d2b04e513552fd651e6..b111e29aa074201b25f0fa22594e4ac8fdeb45b1 100644 (file)
@@ -230,9 +230,15 @@ function search (value, field, start, count, sort, callback) {
   findWithCount.call(this, query, start, count, sort, callback)
 }
 
-// TODO
-function seedAllExisting () {
+function seedAllExisting (callback) {
+  listOwned.call(this, function (err, videos) {
+    if (err) return callback(err)
 
+    async.each(videos, function (video, callbackEach) {
+      const videoPath = pathUtils.join(uploadsDir, video.namePath)
+      seed(videoPath, callbackEach)
+    }, callback)
+  })
 }
 
 // ---------------------------------------------------------------------------