diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/video-channel.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/video-playlist.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/videos/update.ts | 2 | ||||
-rw-r--r-- | server/helpers/database-utils.ts | 11 | ||||
-rw-r--r-- | server/lib/activitypub/actors/updater.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/videos/updater.ts | 6 | ||||
-rw-r--r-- | server/tests/api/live/live-fast-restream.ts | 7 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 2 |
8 files changed, 13 insertions, 23 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 5b9fb794a..c6d144f79 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -310,7 +310,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response) | |||
310 | 310 | ||
311 | // If the transaction is retried, sequelize will think the object has not changed | 311 | // If the transaction is retried, sequelize will think the object has not changed |
312 | // So we need to restore the previous fields | 312 | // So we need to restore the previous fields |
313 | resetSequelizeInstance(videoChannelInstance) | 313 | await resetSequelizeInstance(videoChannelInstance) |
314 | 314 | ||
315 | throw err | 315 | throw err |
316 | } | 316 | } |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 08b0f971d..de32dec88 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -276,7 +276,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response) | |||
276 | 276 | ||
277 | // If the transaction is retried, sequelize will think the object has not changed | 277 | // If the transaction is retried, sequelize will think the object has not changed |
278 | // So we need to restore the previous fields | 278 | // So we need to restore the previous fields |
279 | resetSequelizeInstance(videoPlaylistInstance) | 279 | await resetSequelizeInstance(videoPlaylistInstance) |
280 | 280 | ||
281 | throw err | 281 | throw err |
282 | } | 282 | } |
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index e6197c4b1..5ab54a006 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts | |||
@@ -152,7 +152,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
152 | } catch (err) { | 152 | } catch (err) { |
153 | // If the transaction is retried, sequelize will think the object has not changed | 153 | // If the transaction is retried, sequelize will think the object has not changed |
154 | // So we need to restore the previous fields | 154 | // So we need to restore the previous fields |
155 | resetSequelizeInstance(videoFromReq) | 155 | await resetSequelizeInstance(videoFromReq) |
156 | 156 | ||
157 | throw err | 157 | throw err |
158 | } finally { | 158 | } finally { |
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 0e6b35503..da8fb0d54 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts | |||
@@ -70,16 +70,8 @@ function transactionRetryer <T> (func: (err: any, data: T) => any) { | |||
70 | 70 | ||
71 | // --------------------------------------------------------------------------- | 71 | // --------------------------------------------------------------------------- |
72 | 72 | ||
73 | function updateInstanceWithAnother <M, T extends U, U extends Model<M>> (instanceToUpdate: T, baseInstance: U) { | ||
74 | const obj = baseInstance.toJSON() | ||
75 | |||
76 | for (const key of Object.keys(obj)) { | ||
77 | instanceToUpdate[key] = obj[key] | ||
78 | } | ||
79 | } | ||
80 | |||
81 | function resetSequelizeInstance <T> (instance: Model<T>) { | 73 | function resetSequelizeInstance <T> (instance: Model<T>) { |
82 | instance.set(instance.previous()) | 74 | return instance.reload() |
83 | } | 75 | } |
84 | 76 | ||
85 | function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> ( | 77 | function filterNonExistingModels <T extends { hasSameUniqueKeysThan (other: T): boolean }> ( |
@@ -113,7 +105,6 @@ export { | |||
113 | resetSequelizeInstance, | 105 | resetSequelizeInstance, |
114 | retryTransactionWrapper, | 106 | retryTransactionWrapper, |
115 | transactionRetryer, | 107 | transactionRetryer, |
116 | updateInstanceWithAnother, | ||
117 | afterCommitIfTransaction, | 108 | afterCommitIfTransaction, |
118 | filterNonExistingModels, | 109 | filterNonExistingModels, |
119 | deleteAllModels, | 110 | deleteAllModels, |
diff --git a/server/lib/activitypub/actors/updater.ts b/server/lib/activitypub/actors/updater.ts index 73bdf1edc..5a92e7a22 100644 --- a/server/lib/activitypub/actors/updater.ts +++ b/server/lib/activitypub/actors/updater.ts | |||
@@ -52,11 +52,11 @@ export class APActorUpdater { | |||
52 | logger.info('Remote account %s updated', this.actorObject.url) | 52 | logger.info('Remote account %s updated', this.actorObject.url) |
53 | } catch (err) { | 53 | } catch (err) { |
54 | if (this.actor !== undefined) { | 54 | if (this.actor !== undefined) { |
55 | resetSequelizeInstance(this.actor) | 55 | await resetSequelizeInstance(this.actor) |
56 | } | 56 | } |
57 | 57 | ||
58 | if (this.accountOrChannel !== undefined) { | 58 | if (this.accountOrChannel !== undefined) { |
59 | resetSequelizeInstance(this.accountOrChannel) | 59 | await resetSequelizeInstance(this.accountOrChannel) |
60 | } | 60 | } |
61 | 61 | ||
62 | // This is just a debug because we will retry the insert | 62 | // This is just a debug because we will retry the insert |
diff --git a/server/lib/activitypub/videos/updater.ts b/server/lib/activitypub/videos/updater.ts index 3677dc3bb..6ddd2301b 100644 --- a/server/lib/activitypub/videos/updater.ts +++ b/server/lib/activitypub/videos/updater.ts | |||
@@ -88,7 +88,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder { | |||
88 | 88 | ||
89 | return videoUpdated | 89 | return videoUpdated |
90 | } catch (err) { | 90 | } catch (err) { |
91 | this.catchUpdateError(err) | 91 | await this.catchUpdateError(err) |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
@@ -154,9 +154,9 @@ export class APVideoUpdater extends APVideoAbstractBuilder { | |||
154 | videoUpdated.VideoLive = null | 154 | videoUpdated.VideoLive = null |
155 | } | 155 | } |
156 | 156 | ||
157 | private catchUpdateError (err: Error) { | 157 | private async catchUpdateError (err: Error) { |
158 | if (this.video !== undefined) { | 158 | if (this.video !== undefined) { |
159 | resetSequelizeInstance(this.video) | 159 | await resetSequelizeInstance(this.video) |
160 | } | 160 | } |
161 | 161 | ||
162 | // This is just a debug because we will retry the insert | 162 | // This is just a debug because we will retry the insert |
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts index 4e30feaef..2169393c2 100644 --- a/server/tests/api/live/live-fast-restream.ts +++ b/server/tests/api/live/live-fast-restream.ts | |||
@@ -2,11 +2,10 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { wait } from '@shared/core-utils' | 4 | import { wait } from '@shared/core-utils' |
5 | import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models' | 5 | import { LiveVideoCreate, VideoPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
9 | makeRawRequest, | ||
10 | PeerTubeServer, | 9 | PeerTubeServer, |
11 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
12 | setDefaultVideoChannel, | 11 | setDefaultVideoChannel, |
@@ -81,8 +80,8 @@ describe('Fast restream in live', function () { | |||
81 | 80 | ||
82 | try { | 81 | try { |
83 | await server.live.getSegmentFile({ videoUUID: liveId, segment: 0, playlistNumber: 0 }) | 82 | await server.live.getSegmentFile({ videoUUID: liveId, segment: 0, playlistNumber: 0 }) |
84 | await makeRawRequest({ url: video.streamingPlaylists[0].playlistUrl, expectedStatus: HttpStatusCode.OK_200 }) | 83 | await server.streamingPlaylists.get({ url: video.streamingPlaylists[0].playlistUrl }) |
85 | await makeRawRequest({ url: video.streamingPlaylists[0].segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 }) | 84 | await server.streamingPlaylists.getSegmentSha256({ url: video.streamingPlaylists[0].segmentsSha256Url }) |
86 | } catch (err) { | 85 | } catch (err) { |
87 | // FIXME: try to debug error in CI "Unexpected end of JSON input" | 86 | // FIXME: try to debug error in CI "Unexpected end of JSON input" |
88 | console.error(err) | 87 | console.error(err) |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 72f833ec2..9fd52933f 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -213,7 +213,7 @@ describe('Test a single server', function () { | |||
213 | }) | 213 | }) |
214 | 214 | ||
215 | it('Should upload 6 videos', async function () { | 215 | it('Should upload 6 videos', async function () { |
216 | this.timeout(25000) | 216 | this.timeout(50000) |
217 | 217 | ||
218 | const videos = new Set([ | 218 | const videos = new Set([ |
219 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', | 219 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', |