Skip to content

Commit 82cbcca

Browse files
authored
Merge pull request #188 from pluginpal/feature/prevent-deadlock
fix: prevent deadlocks from happening by using the native deleteMany …
2 parents de693c7 + 801f859 commit 82cbcca

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

.changeset/chilly-melons-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pluginpal/webtools-core": patch
3+
---
4+
5+
Prevent deadlocks from happening by using the native deleteMany service

packages/core/server/admin-api/services/bulk-generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const generateUrlAliases = async (parms: GenerateParams) => {
7979
await Promise.all(types.map(async (type) => {
8080
if (generationType === 'all') {
8181
// Delete all the URL aliases for the given type.
82-
await getPluginService('url-alias').deleteMany({
82+
await strapi.entityService.deleteMany('plugin::webtools.url-alias', {
8383
// @ts-ignore
8484
locale: 'all',
8585
filters: {
@@ -90,7 +90,7 @@ const generateUrlAliases = async (parms: GenerateParams) => {
9090

9191
if (generationType === 'only_generated') {
9292
// Delete all the auto generated URL aliases of the given type.
93-
await getPluginService('url-alias').deleteMany({
93+
await strapi.entityService.deleteMany('plugin::webtools.url-alias', {
9494
// @ts-ignore
9595
locale: 'all',
9696
filters: {
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import { factories } from '@strapi/strapi';
2-
import { EntityService, Common } from '@strapi/types';
32

43
/**
54
* URL alias service
65
*/
76

87
const contentTypeSlug = 'plugin::webtools.url-alias';
98

10-
export default factories.createCoreService(contentTypeSlug, ({ strapi }) => ({
11-
deleteMany: async (params: EntityService.Params.Pick<Common.UID.ContentType, 'filters'>) => {
12-
const toBeDeletedEntities = await strapi.entityService.findMany(contentTypeSlug, params);
13-
14-
await Promise.all(toBeDeletedEntities.map(async (entity) => {
15-
await strapi.entityService.delete(contentTypeSlug, entity.id);
16-
}));
17-
18-
return true;
19-
},
20-
}));
9+
export default factories.createCoreService(contentTypeSlug);

0 commit comments

Comments
 (0)