Skip to content

Commit

Permalink
fix: init plugin conflict on e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-w committed Sep 14, 2024
1 parent 0b9225c commit 03973f7
Showing 1 changed file with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,40 @@ export class OfficialPluginInitService implements OnModuleInit {
'Content-Type': mimetype,
});
// check if the attachment exists for locking
await this.prismaService
const rows = await this.prismaService
.txClient()
.$queryRawUnsafe(
this.knex('attachments').select('token').where('token', id).forUpdate().toString()
);

await this.prismaService.txClient().attachments.upsert({
create: {
token: id,
path,
size,
width,
height,
hash,
mimetype,
createdBy: 'system',
},
update: {
size,
width,
height,
hash,
mimetype,
lastModifiedBy: 'system',
},
where: {
token: id,
deletedTime: null,
},
});
.$queryRawUnsafe<
unknown[]
>(this.knex('attachments').select('token').where('token', id).forUpdate().toString());
if (rows.length > 0) {
await this.prismaService.txClient().attachments.create({
data: {
token: id,
path,
size,
width,
height,
hash,
mimetype,
createdBy: 'system',
},
});
} else {
await this.prismaService.txClient().attachments.update({
data: {
size,
width,
height,
hash,
mimetype,
lastModifiedBy: 'system',
},
where: {
token: id,
deletedTime: null,
},
});
}
return `/${path}/${id}`;
}

Expand Down

0 comments on commit 03973f7

Please sign in to comment.