mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
rollback on all errors
This commit is contained in:
parent
7c2dcd4b2d
commit
ef02eebcf4
@ -68,6 +68,12 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
||||
return restore.deleteRecords(this.strapi, this.options.restore);
|
||||
}
|
||||
|
||||
async rollback(e: Error): Promise<void> {
|
||||
await this.transaction(async () => {
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
|
||||
async beforeTransfer() {
|
||||
if (!this.strapi) {
|
||||
throw new Error('Strapi instance not found');
|
||||
|
@ -30,6 +30,7 @@ export const createTransaction = async (strapi: Strapi) => {
|
||||
const res = await fn(trx);
|
||||
e.emit(uuid, { data: res });
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
e.emit(uuid, { error });
|
||||
}
|
||||
}
|
||||
@ -54,7 +55,7 @@ export const createTransaction = async (strapi: Strapi) => {
|
||||
}
|
||||
|
||||
if (error) {
|
||||
reject(data);
|
||||
reject(error);
|
||||
}
|
||||
resolve(undefined);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user