mirror of https://github.com/Chocobozzz/PeerTube
Fix "Correctly save transaction with retries"
parent
89e3951587
commit
18f13f43ec
|
@ -76,11 +76,13 @@ function saveInTransactionWithRetries <T extends Pick<Model, 'save' | 'changed'>
|
||||||
return sequelizeTypescript.transaction(async transaction => {
|
return sequelizeTypescript.transaction(async transaction => {
|
||||||
try {
|
try {
|
||||||
await model.save({ transaction })
|
await model.save({ transaction })
|
||||||
} catch {
|
} catch (err) {
|
||||||
// Reinit changed keys
|
// Reinit changed keys
|
||||||
for (const key of changedKeys) {
|
for (const key of changedKeys) {
|
||||||
model.changed(key as keyof Model, true)
|
model.changed(key as keyof Model, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw err
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue