aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-27 12:05:19 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-27 12:14:53 +0100
commitcddadde81f91219204cec1f4057a191c02a70894 (patch)
tree06f984ffe21628f6a02f8706a2781e8b6cce2dc7 /server/controllers
parentb09ce6455f8e2bf9dd741532e6ad09309880ff74 (diff)
downloadPeerTube-cddadde81f91219204cec1f4057a191c02a70894.tar.gz
PeerTube-cddadde81f91219204cec1f4057a191c02a70894.tar.zst
PeerTube-cddadde81f91219204cec1f4057a191c02a70894.zip
Server: assert remoteId and host pair is unique
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/remote/videos.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js
index 83d9b98bf..f8b4949cd 100644
--- a/server/controllers/api/remote/videos.js
+++ b/server/controllers/api/remote/videos.js
@@ -79,6 +79,16 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
79 79
80 databaseUtils.startSerializableTransaction, 80 databaseUtils.startSerializableTransaction,
81 81
82 function assertRemoteIdAndHostUnique (t, callback) {
83 db.Video.loadByHostAndRemoteId(fromPod.host, videoToCreateData.remoteId, function (err, video) {
84 if (err) return callback(err)
85
86 if (video) return callback(new Error('RemoteId and host pair is not unique.'))
87
88 return callback(null, t)
89 })
90 },
91
82 function findOrCreateAuthor (t, callback) { 92 function findOrCreateAuthor (t, callback) {
83 const name = videoToCreateData.author 93 const name = videoToCreateData.author
84 const podId = fromPod.id 94 const podId = fromPod.id