fix: asset update race condition

This commit is contained in:
Daniel Dietzler
2025-12-04 15:33:44 +01:00
committed by mertalev
parent 29827f6f08
commit 75889f992e
2 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`ALTER TABLE "asset_exif" ADD "lockedProperties" character varying[] NOT NULL DEFAULT '{}';`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`ALTER TABLE "asset_exif" DROP COLUMN "lockedProperties";`.execute(db);
}

View File

@@ -226,7 +226,7 @@ describe(AssetService.name, () => {
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
{ assetId: 'asset-1', description: 'Test description' },
{ assetId: 'asset-1', description: 'Test description', lockedProperties: ['description'] },
{ lockedPropertiesBehavior: 'update' },
);
});
@@ -242,6 +242,7 @@ describe(AssetService.name, () => {
{
assetId: 'asset-1',
rating: 3,
lockedProperties: ['rating'],
},
{ lockedPropertiesBehavior: 'update' },
);