]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/remote.js
Server: fix logs when adding a remote video
[github/Chocobozzz/PeerTube.git] / server / controllers / api / remote.js
index 4085deb2d7e46309fc0257e5d1f35271c1e3d6c5..2d0db51c02e47435a10f8bdbacf718c10bfd26b8 100644 (file)
@@ -53,13 +53,17 @@ function remoteVideos (req, res, next) {
 }
 
 function addRemoteVideo (videoToCreateData, callback) {
-  logger.debug('Adding remote video %s.', videoToCreateData.magnetUri)
-
-  // Mongoose pre hook will automatically create the thumbnail on disk
-  videoToCreateData.thumbnail = videoToCreateData.thumbnailBase64
+  logger.debug('Adding remote video "%s".', videoToCreateData.name)
 
   const video = new Video(videoToCreateData)
-  video.save(callback)
+  Video.generateThumbnailFromBase64(video, videoToCreateData.thumbnailBase64, function (err) {
+    if (err) {
+      logger.error('Cannot generate thumbnail from base 64 data.', { error: err })
+      return callback(err)
+    }
+
+    video.save(callback)
+  })
 }
 
 function removeRemoteVideo (videoToRemoveData, fromHost, callback) {