aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/remote/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/remote/videos.js')
-rw-r--r--server/controllers/api/remote/videos.js38
1 files changed, 12 insertions, 26 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js
index e8279fe2e..bfe61a35c 100644
--- a/server/controllers/api/remote/videos.js
+++ b/server/controllers/api/remote/videos.js
@@ -146,26 +146,19 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
146 video.setTags(tagInstances, options).asCallback(function (err) { 146 video.setTags(tagInstances, options).asCallback(function (err) {
147 return callback(err, t) 147 return callback(err, t)
148 }) 148 })
149 } 149 },
150
151 databaseUtils.commitTransaction
150 152
151 ], function (err, t) { 153 ], function (err, t) {
152 if (err) { 154 if (err) {
153 // This is just a debug because we will retry the insert 155 // This is just a debug because we will retry the insert
154 logger.debug('Cannot insert the remote video.', { error: err }) 156 logger.debug('Cannot insert the remote video.', { error: err })
155 157 return databaseUtils.rollbackTransaction(err, t, finalCallback)
156 // Abort transaction?
157 if (t) t.rollback()
158
159 return finalCallback(err)
160 } 158 }
161 159
162 // Commit transaction 160 logger.info('Remote video %s inserted.', videoToCreateData.name)
163 t.commit().asCallback(function (err) { 161 return finalCallback(null)
164 if (err) return finalCallback(err)
165
166 logger.info('Remote video %s inserted.', videoToCreateData.name)
167 return finalCallback(null)
168 })
169 }) 162 })
170} 163}
171 164
@@ -222,26 +215,19 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {
222 videoInstance.setTags(tagInstances, options).asCallback(function (err) { 215 videoInstance.setTags(tagInstances, options).asCallback(function (err) {
223 return callback(err, t) 216 return callback(err, t)
224 }) 217 })
225 } 218 },
219
220 databaseUtils.commitTransaction
226 221
227 ], function (err, t) { 222 ], function (err, t) {
228 if (err) { 223 if (err) {
229 // This is just a debug because we will retry the insert 224 // This is just a debug because we will retry the insert
230 logger.debug('Cannot update the remote video.', { error: err }) 225 logger.debug('Cannot update the remote video.', { error: err })
231 226 return databaseUtils.rollbackTransaction(err, t, finalCallback)
232 // Abort transaction?
233 if (t) t.rollback()
234
235 return finalCallback(err)
236 } 227 }
237 228
238 // Commit transaction 229 logger.info('Remote video %s updated', videoAttributesToUpdate.name)
239 t.commit().asCallback(function (err) { 230 return finalCallback(null)
240 if (err) return finalCallback(err)
241
242 logger.info('Remote video %s updated', videoAttributesToUpdate.name)
243 return finalCallback(null)
244 })
245 }) 231 })
246} 232}
247 233