mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 08:52:26 +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);
|
return restore.deleteRecords(this.strapi, this.options.restore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async rollback(e: Error): Promise<void> {
|
||||||
|
await this.transaction(async () => {
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async beforeTransfer() {
|
async beforeTransfer() {
|
||||||
if (!this.strapi) {
|
if (!this.strapi) {
|
||||||
throw new Error('Strapi instance not found');
|
throw new Error('Strapi instance not found');
|
||||||
|
@ -30,6 +30,7 @@ export const createTransaction = async (strapi: Strapi) => {
|
|||||||
const res = await fn(trx);
|
const res = await fn(trx);
|
||||||
e.emit(uuid, { data: res });
|
e.emit(uuid, { data: res });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
await trx.rollback();
|
||||||
e.emit(uuid, { error });
|
e.emit(uuid, { error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +55,7 @@ export const createTransaction = async (strapi: Strapi) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(data);
|
reject(error);
|
||||||
}
|
}
|
||||||
resolve(undefined);
|
resolve(undefined);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user