diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-15 19:13:16 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-15 19:13:16 +0100 |
commit | d6a5b018b89f9d2569ca7435b0e270095c93cc17 (patch) | |
tree | c7f24df4853ad2de7934dfa926ef915222a38277 /server/controllers/api/remote/videos.js | |
parent | a7721e62c028f54c1d165b53ac1a7a60b6c3b82e (diff) | |
download | PeerTube-d6a5b018b89f9d2569ca7435b0e270095c93cc17.tar.gz PeerTube-d6a5b018b89f9d2569ca7435b0e270095c93cc17.tar.zst PeerTube-d6a5b018b89f9d2569ca7435b0e270095c93cc17.zip |
Server: retryer transaction wrapper refractoring
Diffstat (limited to 'server/controllers/api/remote/videos.js')
-rw-r--r-- | server/controllers/api/remote/videos.js | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js index c45a86dbb..9d007246f 100644 --- a/server/controllers/api/remote/videos.js +++ b/server/controllers/api/remote/videos.js | |||
@@ -66,19 +66,12 @@ function remoteVideos (req, res, next) { | |||
66 | 66 | ||
67 | // Handle retries on fail | 67 | // Handle retries on fail |
68 | function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback) { | 68 | function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback) { |
69 | utils.transactionRetryer( | 69 | const options = { |
70 | function (callback) { | 70 | arguments: [ videoToCreateData, fromPod ], |
71 | return addRemoteVideo(videoToCreateData, fromPod, callback) | 71 | errorMessage: 'Cannot insert the remote video with many retries.' |
72 | }, | 72 | } |
73 | function (err) { | ||
74 | if (err) { | ||
75 | logger.error('Cannot insert the remote video with many retries.', { error: err }) | ||
76 | } | ||
77 | 73 | ||
78 | // Do not return the error, continue the process | 74 | utils.retryWrapper(addRemoteVideo, options, finalCallback) |
79 | return finalCallback(null) | ||
80 | } | ||
81 | ) | ||
82 | } | 75 | } |
83 | 76 | ||
84 | function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { | 77 | function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { |
@@ -182,19 +175,12 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { | |||
182 | 175 | ||
183 | // Handle retries on fail | 176 | // Handle retries on fail |
184 | function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalCallback) { | 177 | function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalCallback) { |
185 | utils.transactionRetryer( | 178 | const options = { |
186 | function (callback) { | 179 | arguments: [ fromPod, videoAttributesToUpdate ], |
187 | return updateRemoteVideo(videoAttributesToUpdate, fromPod, callback) | 180 | errorMessage: 'Cannot update the remote video with many retries' |
188 | }, | 181 | } |
189 | function (err) { | ||
190 | if (err) { | ||
191 | logger.error('Cannot update the remote video with many retries.', { error: err }) | ||
192 | } | ||
193 | 182 | ||
194 | // Do not return the error, continue the process | 183 | utils.retryWrapper(updateRemoteVideo, options, finalCallback) |
195 | return finalCallback(null) | ||
196 | } | ||
197 | ) | ||
198 | } | 184 | } |
199 | 185 | ||
200 | function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { | 186 | function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { |