diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-14 08:59:27 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-14 09:03:22 +0100 |
commit | 4565774669bc3c1b11cc726d577946953dbe53c5 (patch) | |
tree | ee0e41e06245861a0de896684caa388f82cc3470 /server/lib/activitypub/actors/updater.ts | |
parent | 4c61660a0ab6224079c67d8282b282772a0772e4 (diff) | |
download | PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.tar.gz PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.tar.zst PeerTube-4565774669bc3c1b11cc726d577946953dbe53c5.zip |
Fix retrying update on sql serialization conflict
Diffstat (limited to 'server/lib/activitypub/actors/updater.ts')
-rw-r--r-- | server/lib/activitypub/actors/updater.ts | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/server/lib/activitypub/actors/updater.ts b/server/lib/activitypub/actors/updater.ts index fe94af9f1..137980460 100644 --- a/server/lib/activitypub/actors/updater.ts +++ b/server/lib/activitypub/actors/updater.ts | |||
@@ -13,19 +13,12 @@ export class APActorUpdater { | |||
13 | 13 | ||
14 | private accountOrChannel: MAccount | MChannel | 14 | private accountOrChannel: MAccount | MChannel |
15 | 15 | ||
16 | private readonly actorFieldsSave: object | ||
17 | private readonly accountOrChannelFieldsSave: object | ||
18 | |||
19 | constructor ( | 16 | constructor ( |
20 | private readonly actorObject: ActivityPubActor, | 17 | private readonly actorObject: ActivityPubActor, |
21 | private readonly actor: MActorFull | 18 | private readonly actor: MActorFull |
22 | ) { | 19 | ) { |
23 | this.actorFieldsSave = this.actor.toJSON() | ||
24 | |||
25 | if (this.actorObject.type === 'Group') this.accountOrChannel = this.actor.VideoChannel | 20 | if (this.actorObject.type === 'Group') this.accountOrChannel = this.actor.VideoChannel |
26 | else this.accountOrChannel = this.actor.Account | 21 | else this.accountOrChannel = this.actor.Account |
27 | |||
28 | this.accountOrChannelFieldsSave = this.accountOrChannel.toJSON() | ||
29 | } | 22 | } |
30 | 23 | ||
31 | async update () { | 24 | async update () { |
@@ -58,12 +51,12 @@ export class APActorUpdater { | |||
58 | 51 | ||
59 | logger.info('Remote account %s updated', this.actorObject.url) | 52 | logger.info('Remote account %s updated', this.actorObject.url) |
60 | } catch (err) { | 53 | } catch (err) { |
61 | if (this.actor !== undefined && this.actorFieldsSave !== undefined) { | 54 | if (this.actor !== undefined) { |
62 | resetSequelizeInstance(this.actor, this.actorFieldsSave) | 55 | resetSequelizeInstance(this.actor) |
63 | } | 56 | } |
64 | 57 | ||
65 | if (this.accountOrChannel !== undefined && this.accountOrChannelFieldsSave !== undefined) { | 58 | if (this.accountOrChannel !== undefined) { |
66 | resetSequelizeInstance(this.accountOrChannel, this.accountOrChannelFieldsSave) | 59 | resetSequelizeInstance(this.accountOrChannel) |
67 | } | 60 | } |
68 | 61 | ||
69 | // This is just a debug because we will retry the insert | 62 | // This is just a debug because we will retry the insert |